root icon indicating copy to clipboard operation
root copied to clipboard

[PyROOT] Importing ROOT in JupyterLab reduces kernel performance

Open agoose77 opened this issue 4 years ago • 4 comments

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 avatar Mar 25 '21 11:03 agoose77

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 avatar Mar 25 '21 14:03 agoose77

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).

agoose77 avatar Mar 25 '21 15:03 agoose77

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

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

etejedor avatar Apr 29 '21 13:04 etejedor

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

agoose77 avatar Apr 29 '21 13:04 agoose77