How to make cargo check faster?

My setup is pretty good:

Hardware
i7-10700F
2TB SSD NVMe ADATA SX8200 Pro

Software
Windows 10 Pro Latest update
Rustc 1.54.0 (a178d0322 2021-07-26)
VS Code Version: 1.61.2
Latest Rust extension for VS Code. Version 0.7.8
All settings are default as far as I know..

My problem is why cargo check takes 5s or more ?
every time I typed, it takes so long for the syntax highlighting to refresh.
And I noticed that as the project grows bigger, the longer it takes to finish checking.

What can I do to mitigate this ?
Can I exclude the third-party dependencies (Cargo.toml) check as I just want to check within my own codes ?

Thank you in advance.

I'm unfamiliar with the "standard" rust extension (i.e. I never used it) so I can't comment on whether your observations make sense or you're doing something wrong. I know that for rust analyzer there's no cargo check involved until you save a file, AFAIR I've never had any performance issues with it on something like syntax highlighting while typing, and it's more feature-rich anyway. Maybe you want to give it a try?

5s for the first run of cargo check is expected — it needs to scan dependencies too. It should be ~1s later.

From what I've heard file system access in Windows can get pretty slow when 3rd party applications like antivirus hook up to listen to filesystem events. Try disabling such background software and see if that helps.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.