I have recently experienced severe slowdown in Openwrt compilation. I think that I have now found the culprit for my recent compiling slowness. I write this as warning for others.
I noticed that build time of my R7800 build (after make clean but using the existing toolchain, so just the plain firmware), grew from some 25 minutes (2 weeks ago) to some 80 minutes (now) in Ubuntu 18.04 in Virtualbox in Windows10 x64. In addition to Openwrt source commits, there have been both some minor updates to Ubuntu 18.04 and also the jump from VirtualBox 5.2.18 to 5.2.20. So I have wondered if this is just something caused by new Virtualbox version or some Ubuntu updates, or something in the Openwrt.
However, it is likely not Virtualbox or Ubuntu, but Windows 10 trying to be secure.
There is a new Windows 10 patch KB4100347 for Intel processor microcode to tackle the Spectre v2 vulnerability CVE 2017-5715 in Intel processors. Windows 10 installed that patch for me on 12.10.2018. The build jobs before that were quick, and the builds after that have been a nightmare.
Reverting that patch decreased the Openwrt compile time from 80+ minutes back to 25-30 minutes on Ubuntu 18.04 in Virtualbox 5.2.18.
Not sure if that is due to specifically Ubuntu-Virtualbox-Windows10 combination with my hardware, but the patch kills the compiling performance in the Ubuntu guest in my case. I will likely need to update the 4-year old Haswell motherboard & CPU to Spectre-proof new hardware versions in intermediate future (once Intel really gets the act together).
I am guessing, but likely the same microcode update will sooner or later hit the Linux distros, so this is likely not just a Windows 10 issue. (But of course the extreme slowness might be due to Windows 10 - Virtualbox - Ubuntu combination)
WSL is faster if you disable Windows Defender while you're compiling. It was still slower than Virtualbox before the spectre patches, but maybe it's faster now.
I'm a bit more curious why you'd use Virtualbox rather than Hyper-V or VMWare Player as from I can personally tell it's really slow and looking at various benchmarks Virtualbox pretty much always ends up last (worst performance).
Well, it works.
I have just started to use it years ago, and have never evaluated the others. I only use Linux for openwrt stuff, so it is not a major issue. A compilation time of 25 minutes (using 2 CPU cores) is quite reasonable as I can still use the PC for other stuff at the same time.
I tried using another drive (as /mnt/v ) for the build, but got prerequisite warnings about non-case-sensitive drive, so I used the main emulated Linux rootfs in the end.
It is nowadays possible to move the Linux rootfs from C: to another drive with 3rd-party tools (although by default the emulated Linux filesystem still gets installed into user's local data directory in C: drive). I used LxRunOffline 3.3.0 to move the already installed Linux rootfs from C: to my V: drive (another SSD that is less full...), and everything seems to work ok. Link to the tool: https://github.com/DDoSolitary/LxRunOffline
I needed to exclude V:/wsl directory from virus scanning to keep performance reasonable. Otherwise my F-Secure virus scanner scanned each compiler process separately (or something like that) and performance was quite weak.
I did not observe any improvement in the compilation speed compared to Ubuntu in VirtualBox, so I do not yet see much benefits in using WSL directly. (But I did not try disabling WindowsDefender like some have suggested)