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

Very slow rendering / locking up browser when plotly-extension rendering multiple charts #171

Open
luck02 opened this issue Dec 7, 2018 · 3 comments

Comments

@luck02
Copy link

luck02 commented Dec 7, 2018

reference issue on jupyterlab jupyterlab/jupyterlab#5738

I'm wondering if anyone else is seeing this behaviour.

I am iteratively creating graphs with relatively modest sized datasets (At most 150 rows). It's all summary data, 3-5 columns * up to 150 rows.

After about 3-4 graphs created in a given page the rendering takes a huge hit in terms of speed. The page seems to freeze up and with 15+ graphs on a given notebook it can take up to 20 minutes to fully render, once it is fully rendered it's reasonably performant (other than being very slow to switch tabs).

using https://hub.docker.com/r/jupyter/all-spark-notebook/tags/ on latest I think that's (14fdfbf9cfc1)

And plotly version: @jupyterlab/plotly-extension v0.18.1

root@47712b0e71c0:~# jupyter --version
4.4.0

root@47712b0e71c0:~# jupyter labextension list
JupyterLab v0.35.4
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v0.38.1  enabled  OK
        @jupyterlab/hub-extension v0.12.0  enabled  OK
        @jupyterlab/plotly-extension v0.18.1  enabled  OK
        jupyterlab_bokeh v0.6.3  enabled  OK

I'm mostly wondering if my use case (multiple distinctly drawn graphs in one notebook is a common or extreme edge case. And really, is anyone else seeing this or just me?

Opening an issue in both places as I'm hoping to get some context around this and I'm not sure which project may have more insight.

@mrtns
Copy link

mrtns commented Dec 14, 2018

I've been encountering the same issue.

My current hunch is that this is caused by plotly-extension writing and re-writing the image/png data?

Specifically, for a given cell output blob:

   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
       },
       "data": [
        {
        ...snip...
        }
       ],
       "layout": {
       }
      },
      "image/png": "...snip...",
      "text/html": [
       "...snip..."
      ],
      "text/vnd.plotly.v1+html": [
       "...snip..."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],

the outputs[x].data."image/png" value is being:

  • written on initial render
  • re-written any time a notebook is opened in a new jupyterlab tab

I plan to do a bit more digging. Thinking out loud, my steps will be:

  • why does plotly-extension add a outputs[x].data."image/png" to cell output?
  • why does plotly-extension re-compute outputs[x].data."image/png" when a notebook is reopened?
  • do the performance problems persist if plotly-extension does not write the image/png data to cell outputs?

@manycoding
Copy link

manycoding commented Apr 25, 2019

@jonmmease I have the same issue in JupyterLab. iframe renderer is faster.

import pandas as pd
import numpy as np
import plotly.graph_objs as go
import plotly.io as pio
pio.renderers.default = "plotly_mimetype"
def create_figures(stats, autosize=True):
    figures = []
    for stat in stats:
        data = [
            go.Bar(
                x=stat[c].values, y=stat.index.values, orientation="h", name=c
            )
            for c in stat.columns
        ]

        layout = go.Layout(
            bargap=0.1,
            height=max(min(len(stat) * 20, 900), 450),
            hovermode="y",
            margin=dict(l=200, t=35),
            xaxis=go.layout.XAxis(range=[0, max(stat.values.max(), 1) * 1.05]),
        )
        layout.autosize = autosize
        figures.append(go.FigureWidget(data, layout))
    return figures

bool_df = pd.DataFrame({"in_stock": np.random.choice(2, 500)}, dtype=bool)
for f in create_figures([bool_df for i in range(5)]):
    pio.show(f)
JupyterLab v0.35.4
Known labextensions:
   app dir: /Users/valery/.local/share/virtualenvs/arche-lm24e12g/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v0.38.1  enabled  OK
        @jupyterlab/plotly-extension v0.18.2  enabled  OK
        jupyterlab-supersave v0.1.0  enabled  OK
        plotlywidget v0.9.0  enabled  OK

@manycoding
Copy link

It seems much faster in Jupyter Lab 1

JupyterLab v1.1.3
Known labextensions:
   app dir: /Users/valery/.local/share/virtualenvs/arche-lm24e12g/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v1.0.1  enabled  OK
        jupyterlab-chart-editor v1.2.0  enabled   X
        jupyterlab-plotly v1.0.0  enabled  OK
        plotlywidget v1.0.0  enabled  OK

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

No branches or pull requests

3 participants