Skip to content

Freezing notebooks #293

@cccs-nik

Description

@cccs-nik

Description

Hey, I investigated this issue because since upgrading to JupyterLab 4.3.0 and adding jupyter-collaboration, a lot of our users have been complaining about killing their servers on JupyterHub. What I found is that notebooks with text outputs get exponentially slower to open. I have a pretty small ~400 KB notebook that I let run for 43 minutes before it loaded as an example.

I ended up on this line of code being extremely slow in jupyter_server_ydoc: https://github.com/jupyterlab/jupyter-collaboration/blob/ed544ba982f55d1fd4a28d5124fbddc3043bbf89/projects/jupyter-server-ydoc/jupyter_server_ydoc/rooms.py#L163

If you dig deeper you will find that it's self._ycells.extend() from jupyter_ydoc that is really slow:

self._ycells.extend([self.create_ycell(cell) for cell in cells])

Indeed, this here is really slow when you pass it massive lists of characters that we now see for text outputs: https://github.com/jupyter-server/pycrdt/blob/f7fb3aebb76c55aff3c82f5008fd135b87de488f/python/pycrdt/_array.py#L100

An easy workaround is commenting out this optimization in create_ycell():

if output.get("output_type") == "stream":
output["text"] = Array(output.get("text", []))

My problematic notebooks now load in a reasonable amount of time but this is just an untested workaround. I'm sure there is a good solution for the problem.

Reproduce

  1. Create a notebook with massive text output(s).
  2. Restart JupyterLab.
  3. Open the notebook.
  4. JupyterLab will be frozen.

Expected behavior

For notebooks to load in a reasonable amount of time even with big text outputs.

Context

@davidbrochart I think this issue might be the most relevant to you as you worked on the new stream outputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions