3 ms·
I'm struggling to think of a situation when running virtualized vs. bare metal where compiler optimizations would matter. Certain hypervisors have the ability
by theevilsharpie 5y ago
I'm struggling to think of a situation when running virtualized vs. bare metal where compiler optimizations would matter.
Certain hypervisors have the ability to disable features on the virtual CPU to enable live migration between different generation physical CPUs, in which case a binary that depends on a disabled virtual CPU feature (a.g., AVX-512) will simply crash (or otherwise fail) when it executes an unsupported instruction.
Other than that, I'm drawing a blank.
Hypervisor performance will vary, but I can't envision any scenario where a binary optimized for the processor's architecture would perform worse than one without any optimizations when running on a VM vs bare metal.
- LinuxBender 5y agoThat's the point. It shouldn't matter but in fact it does. You can see this for yourself if you use the x86_64 optimizations on VM's in benchmark tests. And you will see various results depending on hypervisor used and what application is used. This will even change with time as updates are made to each hypervisor. What I am describing is exactly what is not supposed to happen which is why you are struggling to think of a situation where this should matter. You are being entirely logical.
- altfredd 5y agoIIRC, hypervisors have to preserve CPU registers and other processor-related state when switching between "worlds". This is why mitigations for CPU vulnerabilities affects hypervisors too. Most compilers assume that emitting the code in certain modes (SSE/AVX etc.) have particular cost. That cost may drastically change depending on how the implementation of the hypervisors handles the registers in question.