4 ms·
Just an FYI, C++ compilers can also optimize utilizing runtime info., this is called profile-guided optimization. Basically you compile the program, start it up
by bick_nyers 4y ago
Just an FYI, C++ compilers can also optimize utilizing runtime info., this is called profile-guided optimization. Basically you compile the program, start it up, run tests or scripts that simulate typical user behavior, then you take the output measurements/annotations and stick it into the compiler a second time.
An example of one such optimization that could be made, is branch prediction. Basically you guess the result (true or false) of an if statement. Guessing incorrectly often makes an if statement 5-10x (depending on the CPU design) more expensive inside of the CPU pipeline.
- neonsunset 4y agoThe big difference is AOT requires pre-generated PGO profiles while JIT-based VMs can do it in-flight, "turn it on and get free performance" way. Today, this is supported in - Java HotSpot and GraalVM Enterprise Edition JVMs (at least wikipedia says so) - .NET 6+ Dynamic PGO. It's a feature toggle and may become enabled by default in 8 or later versions. Each release sees improvements to what can be PGO-optimized.