Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Jupyter lab response following Panel 0.13 installation #3531

Closed
ItayKishon opened this issue May 17, 2022 · 24 comments · Fixed by #3537
Closed

Slow Jupyter lab response following Panel 0.13 installation #3531

ItayKishon opened this issue May 17, 2022 · 24 comments · Fixed by #3537

Comments

@ItayKishon
Copy link

ItayKishon commented May 17, 2022

ALL software version info

Windows 10 Business, 10.0.19044 Build 19044
Python 3.9.12
Conda 4.12.0
jupyterlab 3.4.2
panel 0.13.0
(and various others; see requirements.txt below)

Description of expected behavior and the observed behavior

Following installation of Panel 0.13.0, Jupyter lab becomes very slow to respond. This can be seen in various operations, e.g. cell evaluation, autocompletion, or interactive widget response. Operation which are normally instantaneous (e.g. evaluating a=5) can take several seconds (2 up to 5) to complete.
Note that this is without importing anything, specifically not even Panel.

Trying to narrow down the origin of the problem, it seems that previous versions of Panel do not exhibit this behavior. Specifically, I've downgraded to Panel=0.12.6 or 0.12.7, and everything goes back to normal.

Complete, minimal, self-contained example code that reproduces the issue

Creating a new minimal env:

conda create --name Panel_test_0 python=3.9 jupyterlab panel

yields the following slow environment - requirements[Panel_0.13.0].txt

This is fixed by downgrading to Panel=0.12:

conda install panel=0.12

which yields a normal-response environment - requirements[Panel_0.12.6].txt

(checked with 0.12.7, which produces the same results as 0.12.6)

Stack traceback and/or browser JavaScript console output

N/A

Screenshots or screencasts of the bug in action

(I can added if needed)

@philippjfr
Copy link
Member

Thanks for the issue. I'm a little bit skeptical because I (and multiple devs I know) use JupyterLab daily with latest Panel installed and experience no such slowdown. Can you provide some more background? Is there anything non-standard about your environment? Are you running it locally?

@xavArtley
Copy link
Collaborator

I experienced too a slowdown of jupyterlab with panel>=0.13 and jupyterlab>=3.
I switched to vscode jupyter extension to develop with panel now.
My OS is windows 10 too

@jbednar
Copy link
Member

jbednar commented May 17, 2022

Hmm; wonder if it's somehow Panel + JupyterLab + Windows 10? Any other Windows 10 users happily using JupyterLab + Panel and not noticing this issue?

@philippjfr
Copy link
Member

philippjfr commented May 17, 2022

Only thing I can imagine is that the Jupyter serverextension which gets activated automatically in 0.13 is slowing things down. As an experiment could you maybe try to install the older version (0.12.4) and then run:

jupyter serverextension enable panel.io.jupyter_server_extension

If that also slows things down we've found the culprit.

@philippjfr
Copy link
Member

Oh also could you both report your tornado versions.

@ItayKishon-Vayyar
Copy link

ItayKishon-Vayyar commented May 17, 2022

Tornado version: 6.1
(in both scenarios; nothing is downgraded when going from 0.13 to 0.12, apart from the explicit Panel).

Re. panel.io.jupyter_server_extension: it makes no difference.
(I initially tried to enable that for 0.12.6, which - as I understand - was not yet supported? In 0.12.7 I was able to enable it, and it made no difference. I.e. - Jupyter responds swiftly, as it should.)

Also - local installation, and a completely fresh env (creation command specified above, along with requirements.txt).

@xavArtley
Copy link
Collaborator

Same tornado version

@xavArtley
Copy link
Collaborator

I made a small video comparing jupyter lab with panel 0.12.7 & 0.13
https://www.youtube.com/watch?v=r6nBdhKjMyk

panel.io.jupyter_server_extension does not change the 0.12.7 speed

@philippjfr
Copy link
Member

I'm totally guessing at the cause of this but could you try if there's any change with #3534.

@ItayKishon-Vayyar
Copy link

I'm afraid #3534 doesn't fix it.

To make sure I was building the project correctly, I compared 3 versions: the potential fix, latest tag (v0.13.1a7) and the previous release (v0.12.7).

I've also recorded short videos demonstrating the problem. In each one, I evaluate the first cell (note the time it takes), and in the 2nd cell I press TAB immediately after the letter a. You can see that only v0.12 is responding swiftly.

panel_.v0.13.1a7.mp4
panel_.asyncio_loop_jupyter_fix.mp4
panel_.v0.12.7.mp4

@xavArtley
Copy link
Collaborator

Don't know if it's related or if I made a mistake but the preview does not work for me:
image

[E 2022-05-19 10:55:10.517 ServerApp] 500 GET /panel-preview/render/Untitled1.ipynb (::1) 190.84ms referer=http://localhost:8888/panel-preview/render/Untitled1.ipynb
[I 2022-05-19 10:55:13.389 ServerApp] Saving file at /Untitled1.ipynb
[E 2022-05-19 10:55:13.689 ServerApp] Uncaught exception GET /panel-preview/render/Untitled1.ipynb (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/panel-preview/render/Untitled1.ipynb', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\tornado\web.py", line 1704, in _execute   
        result = await result
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\jupyter_server_extension.py", line 116, in get
        page = server_html_page_for_session(
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\bokeh\embed\server.py", line 255, in server_html_page_for_session
        bundle = bundle_for_objs_and_resources(None, resources)
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\bokeh\embed\bundle.py", line 211, in bundle_for_objs_and_resources
        js_files.extend(js_resources.js_files)
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\resources.py", line 299, in js_files
        dist_dir = self.dist_dir
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\resources.py", line 259, in dist_dir
        if self.absolute:
    AttributeError: 'Resources' object has no attribute 'absolute'
[E 2022-05-19 10:55:13.694 ServerApp] {
      "Host": "localhost:8888",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "Referer": "http://localhost:8888/panel-preview/render/Untitled1.ipynb",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"    }
[E 2022-05-19 10:55:13.696 ServerApp] 500 GET /panel-preview/render/Untitled1.ipynb (::1) 196.01ms referer=http://localhost:8888/panel-preview/render/Untitled1.ipynb

@ItayKishon-Vayyar
Copy link

Don't know if it's related or if I made a mistake but the preview does not work for me: image

[E 2022-05-19 10:55:10.517 ServerApp] 500 GET /panel-preview/render/Untitled1.ipynb (::1) 190.84ms referer=http://localhost:8888/panel-preview/render/Untitled1.ipynb
[I 2022-05-19 10:55:13.389 ServerApp] Saving file at /Untitled1.ipynb
[E 2022-05-19 10:55:13.689 ServerApp] Uncaught exception GET /panel-preview/render/Untitled1.ipynb (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/panel-preview/render/Untitled1.ipynb', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\tornado\web.py", line 1704, in _execute   
        result = await result
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\jupyter_server_extension.py", line 116, in get
        page = server_html_page_for_session(
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\bokeh\embed\server.py", line 255, in server_html_page_for_session
        bundle = bundle_for_objs_and_resources(None, resources)
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\bokeh\embed\bundle.py", line 211, in bundle_for_objs_and_resources
        js_files.extend(js_resources.js_files)
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\resources.py", line 299, in js_files
        dist_dir = self.dist_dir
      File "D:\CIVA_RP\CIVA_SIE\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\resources.py", line 259, in dist_dir
        if self.absolute:
    AttributeError: 'Resources' object has no attribute 'absolute'
[E 2022-05-19 10:55:13.694 ServerApp] {
      "Host": "localhost:8888",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "Referer": "http://localhost:8888/panel-preview/render/Untitled1.ipynb",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"    }
[E 2022-05-19 10:55:13.696 ServerApp] 500 GET /panel-preview/render/Untitled1.ipynb (::1) 196.01ms referer=http://localhost:8888/panel-preview/render/Untitled1.ipynb

@xavArtley - I'm not sure, but I've stumbled upon this exact problem, and I believe it has already been fixed (not yet released): #3442
Moreover - as that fix has been merged (AFAIK), and I've tested the latest master, I would guess it's not related to the slowdown issue.

@xavArtley
Copy link
Collaborator

Other experiment if I launch classic notebook from command line I have no slow down
However If I launch classic notebook from the help menu of jupyter lab I have the slow down

@philippjfr
Copy link
Member

So the change in #3534 actually had no effect at all, will get another PR up which hopefully will have the effect that I originally intended.

@philippjfr
Copy link
Member

I'm having a problem reproducing this. When I install 0.13.0 from pip or conda I see the slowdown but if I do a develop install locally I don't. How were you guys installing from the branch?

@xavArtley
Copy link
Collaborator

I don't use a developpement version. I only use pip version.

@philippjfr
Copy link
Member

A proper pip install (without -e) does it, so I'm git bisecting now. Tedious but I'm close.

@ItayKishon
Copy link
Author

My former results are from a plain python setup.py install.
I'm now setting up a dev environment (per https://panel.holoviz.org/developer_guide/index.html), to see if this disappears when on dev.

@philippjfr
Copy link
Member

So git bisect does blame: Patch asyncio event loop policy on windows (#3339), which means my initial guess was correct, just the fix wasn't right. This does confuse me though because according to https://github.com/jupyter/notebook/pull/5907/files the WindowsProactorEventLoopPolicy should be fine for tornado>=6.1 and python>=3.8.

@philippjfr
Copy link
Member

Nevermind, reading that PR, it was actually reverted because:

Looking back at tornado docs, I think we should still be using the selector loop all the time. Performance will be better, as ~everything we do is built add/remove_reader, which are slower when proactor is used do to the extra thread.

So I'll have to find a way to detect properly if we are running in Jupyter and not apply that patch.

@ItayKishon
Copy link
Author

I'm afraid something weird is still going on -
I am reproducing that problem also on dev.

There's a caveat, though: I wasn't able to completely follow the dev setup guide, specifically doit env_create -c pyviz/label/dev -c conda-forge --name=panel_devdev --python=3.9 which gave some error (I'm afraid I haven't saved it. Can reproduce if helpful).

My exact setup commands are as follows:

git checkout v0.13.1a7
conda create --name panel_dev python=3.9 mamba jupyterlab
conda activate panel_dev
mamba install -c pyviz "pyctdev>0.5.0"
doit ecosystem_setup
mamba install pyct bokeh pyviz_comms
python setup.py develop

Above env reproduces the problem.

@philippjfr
Copy link
Member

Fixed in #3537

@ItayKishon
Copy link
Author

Hurray!
#3537 does indeed solve that.

On that note - although I've just recently started using Panel, I find it extremely valuable & powerful. Thank you, and all those involved, for this great project.

@philippjfr
Copy link
Member

Thanks for the kind words and glad we could figure this out. Will release Panel 0.13.1 later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants