Is Java JIT compiling bytecode in a deterministic way - the same optimizations for every run on the same computer?

Will Java JIT compile bytecode with the same optimization every time it starts on the same computer?

Does it take into account dynamic factors, such as the CPU usage at the moment, or will it do the same optimization every time, regardless of time factors?

+6
source share
1 answer

No, optimizations are not deterministic. Even if you run the same single-threaded, fully deterministic program, the sampler is used by JIT to determine which optimization methods a different set may choose.

Another thing that can change the generated machine code is the actual memory location of certain constants that the code refers to. JIT can issue machine instructions that directly access these memory locations, which leads to additional differences between machine code on different passes.

Researchers using Jikes RVM have addressed this issue for their tests using the Compiler Repeat feature.

+4
source

Source: https://habr.com/ru/post/948342/


All Articles