Parsing speed at startup

Dear Cling users,

I am using the Cling interpreter as an embedded network interface, so that RPCs are much simpler to develop. It works exactly like it was supposed.
In order to use it, the interpreter needs to parse the include files of the program. Unfortunately it has dependencies to huge header only libraries like boost and CGAL. Parsing the program’s headers takes about 1-2 mins which is simply too long for the intended use cases like executing tests on the remote system.
Does anyone know if it is possible to speed things up? Can I use “RuntimeUniverse.h” for this purpose? Any other ideas?

Thanks in advance and best regards

Jupp :slight_smile:


That’s surprisingly slow, even for large headers. Can you send us a trace (e.g. callgrind)?

You could pack things into a PCH and pass that to cling through -include-pch.

Cheers, Axel.

Hello Axel,

thank you very much for your answer and sorry for not answering promptly.

Precompiled headers sound very promising and I will give it a try as soon as possible.

I will update this thread accordingly.

Best regards and thank you :slight_smile:

Hi, my original comment got lost, and attaching the callgrind log doesn’t seem to have worked.

Anyway, I was writing the following:
I’m moving Belle2’s reconstruction software to root6 (see my other thread for my experiences) and I also noticed a significant slowdown in startup times from a noticeable, but subsecond, delay to a few seconds (2-3, not measured). According to callgrind virtually all the time (80%) is spent inside clag::Parser::ParseNamespace. Of this time, most of the time is spent in clang::Preprocessor::Lex, below which the computing time spreads out more between different routines.

Edit: since attaching doesn’t seem to work, here’s the callgrind output in my Dropbox: … lgrind.out

Hi Tobi,

Thanks for he nice callgraph! What you see is currently expected, for the beta: we parse headers at startup as a work-around until I have fixed the modules (PCMs).

The original post was about cling and a large header file - where for now we don’t plan to provide the same feature.

Cheers, Axel.

Ok, I didn’t note this subtle difference. I will note though, that also reading a .C file generated for a 2D histogram with lots of bins takes very long, so parsing speed is also an issue outside of startup times.


That’s likely this bug: To verify I’d need the source. Could you attach it, please?

Cheers, Axel.

These are released results so I can attach the actual plot, but it shouldn’t matter much. Just generate a long sequence of TH1::SetBinContent calls :slight_smile:

costh_m_pieta.C (332 KB)

BTW here’s a callgrind profile for evaluating this file. It’s a fairly pathological case, so I’m not surprised that it spends virtually all it’s time in some utility function of clang; the number of calls to clang::SUnit::setHeightDirty() (484e6!) is a bit scary, though.

ps: i quickly tested a hypothesis: removing roughly half the lines from the file leads to 121e6 calls, removing half of that leads to 39e6 calls. In other words, this hits a quadratic bottleneck.


Thanks, so indeed it’s the same bug.

Cheers, Axel.


And it got fixed in clang - we’ll upload the new revision soon (before the ROOT 6 release).

Cheers, Axel.