root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.7k stars 1.28k forks source link

[PyROOT] Importing ROOT in JupyterLab reduces kernel performance #7684

Open agoose77 opened 3 years ago

agoose77 commented 3 years ago

After importing ROOT in a Jupyter Notebook in which Jupyter Widgets are used, the performance of figure interactions like panning and zooming drastically falls off. After identifying ROOT as the culprit, I found that the poor performance is caused by sleeping invoked during these hooks which are run for each kernel execution.

agoose77 commented 3 years ago

OK, I created an implementation of a non-blocking equivalent. I'm sure there are some bugs:

This notebook uses a thread-based trampoline to execute the various blocking waits without interrupting the kernel. The results are displayed asynchronously using the ZMQ event loop (used by the kernel), and the executing cell's context is temporarily restored to ensure results end up (visually) in the right place.

Clearly this would need some more work to replace the existing contents of JupyROOT.helpers.utils, but I hope that it's a starting point for discussion

agoose77 commented 3 years ago

An interactive binder:
Binder

Run all cells in each notebook, and then look at the coordinates in the status-bar as the cursor moves over the plot. In the un-patched case, the input lag increases with time (as more messages are buffered behind the calls to sleep).

etejedor commented 3 years ago

@agoose77 thank you very much for this extensive research you did!

Do you think you could apply this to JupyROOT.helpers.utils?

agoose77 commented 3 years ago

@etejedor sure, I'll add this to my TODO list :)