-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Trim notebook large output for better performance #9594
Trim notebook large output for better performance #9594
Conversation
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
@goanpeca @isabela-pf Thx for your reviews and feedbacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: move this to the body. Putting it in the ctor will help with page load, but won't prevent a notebook slowdown from a large number of DOM nodes accidently being added when a cell outputs too much content.
packages/outputarea/src/widget.ts
Outdated
<div style="margin: 10px" | ||
<pre>Output of this cell has been trimmed on the initial display.</pre> | ||
<pre>Total outputs is ${model.length}, displaying the first ${maximumTopBottomOutput} top and last ${maximumTopBottomOutput} bottom outputs.</pre> | ||
<pre>Run again this cell to get the complete output.</pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea is adding button to click to show all output for this cell. Maybe that's v2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have thought about that indeed for a v2 iteration.
packages/outputarea/src/widget.ts
Outdated
for (let i = 0; i < model.length; i++) { | ||
const output = model.get(i); | ||
this._insertOutput(i, output); | ||
const maximumTopBottomOutput = options.maximumTopBottomOutput || 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if options.maximumTopBottomOutput === 0
disabled this feature so it is backward compatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! will do
@mlucool Can you elaborate a bit on this. I am not sure to fully understand. Thx |
My understanding of this change is that when a user opens a notebook, only the first and last N items are shown for a cell. The problem is if you run a cell and it outputs 10k outputs, a user's notebook may still freeze up due to the number of outputs rendered. By moving the logic out of the ctor (e.g. into |
OK, I see. I was thinking the run as being a workaround for the user to still see the output waiting on the next dev iteration that would show up a button to reveal the unhidden content. I may come up tomorrow with both: moving to _insertOutput have a button (need to test a bit how to implement that and how it potentially affects performance) |
@mlucool I have implemented the reveal of the trimmed outputs when the user clicks on the message + the backwards compatibility if the For the logic move to the insertOutput so that outputs are also trimmed on code execution, I came to read again https://jupyter-client.readthedocs.io/en/stable/messaging.html to make sure we can trigger the end of the execution. I have not (yet) implemented that yet as the output area would need to watch the
|
Looks great!
I don't think this is always true. If you do
To be clearer, I am suggesting as data comes in we do something like this:
That is, as a each new message comes in, start replacing the oldest of the tail after some threshold. |
True.
Sounds like a great idea . The tail will change in live, if the user wants to see the body, he can always click on the message. Let me give it a try. |
Most of the risk is if the network breaks; or if the kernel crash; so I think that should be fine. Note that there is also:
But those limit the rate to protect against accidental |
FYI I am working to take into account the kernel execute_reply so the above behavior is also applicable to new cells. |
A few comments:
|
If this is a show-stopper, we can set the setting
User does not need to rerun to see the output, he just has to click on the message to see the trimmed outpus.
This aims to address outputs with many top divs (eg. more than 100 ), so even the cell has multiple visual outputs, you would not get those 100 visuals.
We have benchmarks in https://github.com/jupyterlab/benchmarks to generate such figures, but this would take quite some work to run them and extract them details. 10 sounds like a reasonable number. We could go to 20 to be sure we don't strip out most of the cells. This is also configurable and the goal is to update that number based on the subsequent RC releases.
See previous answer. |
BTW I need to update the shown message as it says users has to rerun to see the outputs: User has just to click to see the outputs. |
I think |
@mlucool I have changed the setting name to First, let's consider the number of output messages will be 17 and that it is the first time the user runs the cell,.
As a user experience, this is not great as we show and hide directly the There is also a second issue. When listening on the
Unless we find a way to overcome the above 2 issues, I would suggest to revert back to the initial approach where we only show the message on already populated cells. When the user will open the notebook, we will get performance gain as we can apply the trimmed logic. The downside is that the user will still see large outputs on WDYT? |
I opened the notebook in your second screenshot in the first update (i.e. the one that says NameError) in both Lab and Notebook. Even after the pageload, notebook says somewhat usable and I can rerun/clear a cell. Lab basically becomes not responsive to most actions. While I don't have hard data on this, I have a hunch this is due to the CSS/wrapping each in lumino widgets. This means that making this PR work for both load and runtime is pretty important to making lab stable. This state isn't hard to get into if you have a cell that does something highly parallelized and they all have errors. To address the two issues you raised: This means that the clickable info is never removed because it is only added after we are sure it will be needed. This should also remember if that if a user clicked show all output when output 21 came, then output 22 comes, we remember not to hide anything. |
Thanks for clarifying points.
Another set of questions:
* Are we storing the state related to this in the notebook metadata? What
happens if a user reopens a notebook?
* How does this state interact with the other state (scrolling, collapsed)
that determines how outputs are rendered and handled?
…On Thu, Jan 14, 2021 at 12:13 PM Eric Charles ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/notebook-extension/schema/tracker.json
<#9594 (comment)>
:
> @@ -388,6 +388,12 @@
"description": "Defines the observed bottom margin for the virtual notebook, set a positive number of pixels to render cells below the visible view",
"type": "string",
"default": "1000px"
+ },
+ "maxTopBottomCellOutput": {
+ "title": "The maximum number of output cells to display in the top and bottom for cells",
+ "description": "Defines the maximum number of output cells to display in the top and bottom for cells with many outputs. Output in between will be trimmed and not displayed.",
i think the message is there (next line)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9594 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAGXUCP637NZ6GHVMPJHLDSZ5F57ANCNFSM4V5OJRUA>
.
--
Brian E. Granger
Principal Technical Program Manager, AWS AI Platform ([email protected])
On Leave - Professor of Physics and Data Science, Cal Poly
@ellisonbg on GitHub
|
Nope.
By default the output cells will be hidden unless the users clicks the message.
Good question, not sure! |
It the cell output is collapsed, the user can ucollapse it. Depending on the output length, the cell will be shown with or without the trimmed outputs. The some outputs would have been trimmed, the user can still then click on the message and the them like before. For the scroll behavior, the trimmed outputs are not show and not in the DOM, so they will not be impacted. Only on reveal, they would be. |
@goanpeca Thx a lot for your review. I have pushed the needed changes. @ellisonbg Thx for the questions. Anything else we need to provide? I propose to leave this PR open for a few days (this Firday and weekend, so until Monday 18 Jan included). We'd like then if no more concern is raised, to get this merged to release a JupyterLab 2.3.0rc0 version with this in as discussed during the last weekly JupyterLab meeting. |
@goanpeca This PR is ready for final review (lint is fixes, the other notebook js failure is unrelated to these changes and linked to flaky tests previously seen on the 2.x branches) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this work @echarles !
All works as expected
@ellisonbg From today community meeting, I understand you may have improvement proposals to make sure the message is seen by the user (or via CSS or via right-click menu) and you also said that it should prolly not block the merge as we can iterate on the message quality in the next Release Candidates. We have planned resources to release tomorrow 2.3.0RC0. As discussed, it will be much appreciated to get any feedback (merge as it or not). As option, we can set the setting |
I am supportive of this being merged in its current state (pending any code reviews) with a
Nice work though! |
Thx @ellisonbg for your intake and as usual great inputs, reviews and feedbacks to make jupyterlab a greater piece of software for the users. @isabela-pf At some point, we can get advice from you on the actions listed by Brian: Improved styling of the message and/or Context menu items on the output and notebook to show all the outputs and/or A indicator on the output prompt area to show the user there is more output that is being hidden so that can tell this without scrolling as much... andor anything you think would make a great user-experience. |
|
Thanks for this amazing work @echarles and all reviewers for their comments. Merging now. Will cut a release with @blink1073 in a couple of hours! Cheers |
Just to ping everyone here who might be interested, I commented on #9593 since this PR has been merged. |
this feature is very helpful but for the work I do, I need to turn it off. I manage multiple users and would prefer to set the default to Is there a way I can do set this default value using the Thanks fr the help! |
All defaults should be overridable with overrides.json. I too learned about this great feature only recently! |
Thanks @mlucool, that's a cool way of setting user preferences! However, I haven't been able to get it working... I restarted the Jupyter server and refreshed the browser tab but still don't see the changes. Is there anything else I need to do? |
I didn't test this, but you'll want something like this (you need to scope the settings):
|
Thanks @mlucool, I appreciate the help! I've tried to put the code below in
|
I would suggest trying the example in the docs (changing the default theme) first to make sure that you have the file location correct first, then working on getting the right setting name. |
yeah, totally @jasongrout—I've tried that too. Thanks |
References
Fixes #9593
Code changes
Add a
maximumTopBottomOutput
notebook setting and trim outputs that are larger than a predefined multiple of that maximumTopBottomOutput value. A relevant message is shown to the user. If the user runs again the cell, he will get the complete output.User-facing changes
Opening a notebook, the user will be shown with a message for large outputs.
Backwards-incompatible changes
None.