PyRoot imports taking a long time

Hi,
I am using ROOT via python and have a basic simulation that I am running.

The simulation itself works fine, but it is taking 27.5178 seconds to run. After running some diagnostics I have found that 27.0129 seconds of this time is being spent on importing root with the following line:

from ROOT import TFile, TTree, TRandom3, TCanvas, TGraph, TF1, TH1F

I am using a Windows system; and using WSL cmd line to run this program. I am using root-6.24.02.

I was just wondering if anyone had any ideas on how I could speed this up?

Cheers!

Hi @xclbr, thanks for asking!

It would be good to hear @etejedor’s opinion on this. Maybe this is something that improved in the newer ROOT 6.26.04, have you tried using that?

Hello,

What happens if you split those imports, is any of those in particular the reason for the overhead? Those classes come from different libraries, when you do those imports the libraries are loaded for the first time. Still it shouldn’t take that long.

Perhaps @bellenot can also comment?

I have to build ROOT on WSL first. I’ll let you know

So with ROOT master, it takes around 6 seconds the first time, and then something like 2 seconds…

Thanks for your responses; I have tried separating out the imports and timing individually. It seems to not be specific imports causing it but always the first time ROOT is called, so am assuming it is something to do with my build.

Specifically: when I had from ROOT import TTree on the first line of my file it was taking around 35 seconds on that line but when I swapped that with from ROOT import TFile (so TTree import is now on line 2 and TFile import on line 1) it takes less than 0.1 seconds to import TTree on line 2 but 35ish seconds on TFile instead (on line 1).

Should I perhaps re-build root?

Sounds a bit like this (unsolved): “Slow startup”

Can you try with the tip of the main/master branch?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.