One of Microsoft’s goals with Windows 10 is to win back creators, software development is one of the categories Microsoft trying to target. With the introduction of the Windows Subsystem for Linux (WSL), Microsoft opened doors for more developers that were relying on Linux/Unix platform to come back to Windows. However, even with the addition of WSL, Windows still differs greatly in its File System.
The difference between OS’s file system has a huge impact on node.js or front-end web projects. npm or yarn that manages dependencies would often create a large number of files and directories under node_modules. This process is usually slower compared to other OS that’s running on the same hardware. The slowness would be amplified with the real-time antivirus protection by Windows Security (formerly known as Windows Defender). As you can see a regular React-based project running npm install or yarn install would yield a high CPU cycle from Antimalware Service Executable from the Task Manager.
This is because the amount of new dependencies the package manager has sourced and downloaded kicked off the real-time scanner to run through all the thousands of files and folders to scan while installing them.
Normally, a Windows system that has this real-time protection turned on (by default) compare to a Linux machine with the same hardware would be about 5-10 times slower.
To improve the speed on Windows you can disable the real-time protection so the system has more CPU cycle dedicated to the real task instead of sharing the resource by the virus scan.
Go to Start > Windows Security. Under the Virus & threat protection settings go to Manage settings.
Here you should see the “Real-time protection”, turn it off.
Now, you can test the same operation again, you shouldn’t see those processes running. CPU cycle should be now all dedicated to the command you are running from the terminal.
There is an alternative way to disable real-time protection is to launch PowerShell in Administrator and enter the following command.
Set-MpPreference -DisableRealtimeMonitoring $true
By disabling this, depends on the project you are running it will help to cut down close to half of the time it was using previously. If you are running npm or yarn on a daily basis, this optimization is a must.