I am trying to use pyROOT in ipython but I have two issues:
First, it takes 30 seconds to import (I have timed it).
Secondly, after a minute or after having called
import ROOT in ipython, input becomes so delayed as to be totally unusable. There’s a lag on the order of several seconds between pressing a key and the ipython session responding.
I’m on ROOT 6.10.08 and ipython version 5.4.0, with python2.7.
I could put up with the 30s import but the several second lag is genuinely unusable.
Is there something I’m doing wrong? Anyone here familiar with this bug?
Uhm…do you have some special autocompletion plugins enabled or something of this sort?
Differently phrased: do you see the slowdown even if you use a normal python session (not ipython)?
Just to be clear what the issue is: A ~minute after having imported ROOT, the ipython session becomes insanely slow and unresponsive… I had some typos in my original post.
No it does not appear to happen with plain python, just ipython, and I have no plugins, just the plain ipython version in question.
In the previous version of ROOT I used there was no problem whatsoever, but I have only gone to use ipython long after wiping my old build and am therefore not sure which version I come from (it was root6 for sure but not sure exact release)
I am not aware of anyone else ever reporting a problem like this.
Normal python session works fine, ipython has a problem, but you don’t use any extra components, just plain ipython.
I cannot reproduce this on master. I can try to compile and test v6.10/8 tomorrow.
In the meanwhile let’s try to isolate the issue a bit more.
Does the slowdown happen even if you don’t give any other command after
import ROOT? How does CPU and RAM usage look during the slowdown? Is the process busy doing “stuff”? It would be extra cool if you could try to strace it to see what system calls ipython is doing when the slowdown happens.
I tried ipython+v6.10/8 and still no slowdown (on linux).
I am more and more convinced this is an issue with your local setup – I’d like to help but I need to be able to reproduce the problem.
Does the slowdown happen even if you don’t give any other command after import ROOT
No. I have tried
import ROOT and left it for hours without touching the ROOT library itself, and there is no slowdown. When I interact with ROOT, say using
>>> x = ROOT.TH2F("y", "y", 300, -3.0, +3.0, 200, 1, 11)
after ~30s, the lag begins.
There is little to no discernible change in the CPU usage or memory before and after the lag begins.
One thing that I have noticed is that the slowdown coincides exactly with the onset of “AppNap”, there have been reports about this issue elsewhere regarding ipython (perhaps related):
Although I’m on High Sierra (latest Mac). Perhaps at this point I should state that I got ipython via MacPorts.
It would be extra cool if you could try to strace it to see what system calls ipython is doing when the slowdown happens
I don’t know how to do this / what it means.
If the issue you have is the same described in the
ipython issue you linked to, can you try out the workarounds they suggest in that thread?
One is to
pip install appnope and do an
import appnope at the beginning of your ipython session.
The other is reported here:
We’ve had very good responses to jdmarch’s recommendation at MITx 6.00.1x:
Go to Canopy;
Select Python backend
and change it from “Interactive(Qt4)” to “Inline (SVG)”
Also, if the slowdown is due to AppNap, according to that thread this might not be strictly due to ROOT but to a
matplotlib inclusion (which ROOT might do under the hood, I’m not sure)
None of this actually worked to solve my problem. I was mainly linking to show that there are other known cases where appnap may cause problems. I had already tried these solutions myself to no avail.
I’m not the only one with this problem. I know of at least 2 people in my office with this exact issue when using ipython and ROOT.
I have tried using ROOT via macports and ROOT via manual installation and the issue remains in both cases.
If you and the other 2 people confirm that the problem is indeed caused by the interaction of AppNap and a python module that ROOT imports, as it seems to be the case, there are a few things that we can try.
The most obvious is disabling AppNap for ipython – or if that does not work you can disable AppNap on your system when working with pyROOT. I’ll investigate if we can do something about the issue on our side but my best guess for now is that ROOT only indirectly causes the problem by importing modules like matplotlib and Qt, on which we have no control. To be seen.
If it’s ROOT with Cocoa and ROOT’s event loop is not on the main thread - then it’s not a slowdown, it just no events are dispatched properly - NSApplication requires the main thread to work.
@eguiraud I can turn off App Nap system wide and this fixes the issue, but I cannot find a way to turn it off for an arbitrary executable in the most recent OSX release (High Sierra), I think such an ability was removed once App Nap became a more proven feature. Turning it off system wide is not ideal of course due to the negative impact on battery life.
I do find it strange to think that matplotlib may be the problem, as I use matplotlib myself on a semi-frequent basis without issue.
Regardless it is sufficient to call the following before starting your ipython instance
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
and then to switch it back on again (after having imported ROOT and made a call to the ROOT library I believe):
defaults write NSGlobalDomain NSAppSleepDisabled -bool NO
There’s a more elegant work around of this issue for sure but at least I can use ipython with ROOT now.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.