`rust-analyzer` running slow on Win10

Hello Rustaceans! I'm a new Rustacean setting up dev environment with VSCode and rust-analyzer. I observed that rust-analyzer is running about 5 times faster on Linux than on Win10 (I use the same settings as using clippy). Is this behavior expected? Here is my environment:

Win10 (local OS on laptop):

  • MSYS2
  • toolchain: stable-x86_64-pc-windows-gnu

Ubuntu 20.04 (guest OS in VMware on Win10):

  • toolchain: stable-x86_64-unknown-linux-gnu

update: the laptop is ThinkPad P1, using SSD

update: I highly suspect Windows Defender causes this issue. Every time I save my .rs file (this triggers rust-analyzer), the antimalware service will be triggered, and its CPU usage is high. I tried to set the whitelist as follows, but it doesn't work. Any suggestions?

I remember some issues with disk access. Are you using HDD?

Edit: Check walkdir performance under windows · Issue #9847 · rust-lang/rust-analyzer · GitHub

Thanks for replying! No, I'm using SSD. I will update the hardware details.

If it is Microsoft Defender, could you try whitelisting the target folder of your project? I believe that's where rust-analyzer will be storing all the intermediate files it writes to while compiling/checking code.

Thanks! I updated my whitelist to include my workspace folder as follows. Yes, rust-analyzer now runs faster :smiley: (now it runs about 2 times faster on Linux than on Win10)

But still, Windows Defender will be triggered when I save my rust file, which might explain the speed difference between Linux and Win10. So, some more folders should be included in the whitelist. Unfortunately I have no idea now :frowning:

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.