My Raspberry Pi has been compiling Arduino programs in about a tenth the time that my main Windows machine has. The Windows machine is not a slouch – i7-7700HQ with 16GB RAM and a SSD, and it was getting annoying waiting for several minutes while some of the larger ESP programs compiled.
Turns out the antivirus was running full-tilt, scanning every file as it was loaded into the compiler, pinning the CPU.
The fix for me was to set an exception in my AV software for the C:\Users\[yourname]\AppData\Local\Arduino15 folder. It made a huge difference in speed and my laptop no longer sounds like a jet engine when it’s compiling a 20-line program for a microcontroller with 2.5kB of RAM…