JIT optimization level?

Hi,
You are right the .O option is not yet implemented. Currently we do JIT optimizations equivalent to -O1.

If you are interested in comparing the different optimization levels, you could tweak this by modifying the line: interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp:92 to either one of

enum Level { None, // -O0 Less, // -O1 Default, // -O2, -Os Aggressive // -O3 };

By definition the JIT (standing for Just-In-Time compiler) cannot yield the same performance as static compilation (coming from clang). Usually the JIT compiler introduces not so big compilation overhead coming from the per-function compilation at runtime.

In your example, perhaps you have a loop testing the JIT performance, which means that the JIT will kick in only once to compile the function (containing the loop) and thus the performance results should be very close to the ones coming from static compilation with clang.

That said, I’d be very interested to see this performance study :wink:
Cheers,
Vassil

PS: Another important aspect: if the optimization levels are increased this would mean that the JIT will spend more time trying to optimize each function it compiles, which might result at runtime slowdown. In this respect we cannot turn it blindly into O2 or O3 (O3 sometimes breaks the correctness of the code).