Details
-
Sub-task
-
Resolution: Fixed
-
Critical
-
master
-
None
-
None
-
any
Description
Sometimes, interpreting a macro takes much more time than compiling+executing.
I used to blame the optimization level of the executed code, and that might also play a role, but there are cases in which most of the (very relevant) overhead comes from cling instrumenting the code with cling_runtime_internal_throwIfInvalidPointer checks.
The reproducer attached (main.cpp) takes 3.6s to be compiled (-g -O0) and 1.4s to run on my laptop.
When run through root -l -b -q, it takes 18s to complete execution.
Profiling shows that the interpreted version spends a great part of its time in cling_runtime_internal_throwIfInvalidPointer checks – useful at prompt, but probably not so much when running a macro like this.
To run main.cpp one needs to first create its input file with create_file.cpp.
Credits to Stefan Wunsch for the reproducer.