Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.8k
Improve context handling#4453
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
791c149 toe0ef794Comparejasongrout commentedApr 26, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Holding off on this to work on#3499, which is a prerequisite. |
561d94e to0c9343dCompare…ack a document widget.
…ic into the factory.This uses basic parts in a composable way, but puts a lot of burden on the factory and externalizes a lot of the logic that maybe should be inside the document widget.
We still need to make sure that the appropriate promises are in place for the spinner to show while content is loading.
jasongrout commentedMay 12, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Current design question: The InstanceTrackers now provide an IDocumentWidget for document widgets. This means that often people have to interact with the I can explain more - the above may be more a short-hand note to myself about what to bring up in a design discussion. |
jasongrout commentedMay 12, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@blink1073,@afshin - do you remember why we let people change the context of an existing notebook panel? jupyterlab/packages/notebook/src/panel.ts Line 184 inf685892
Is that something we should be careful about preserving, or is it something we can move into the constructor and make readonly? Edit: it seems at some point we had design discussions about passing themodel into the constructor, versus setting the model after constructing the object, but I don't remember the context being part of that discussion |
ian-r-rose commentedMay 24, 2018
Any ideas? I still can't figure out what is going on. |
jasongrout commentedMay 25, 2018
I seem to get some contradictory results. It seems that when I remove the reveal promise, subjectively things are fast again (I should test this again). However, when profiling, it seems that the extra time is spent in a browser layout, laying out thousands of nodes (e.g., all of the internal codemirror text nodes), which I think is maybe triggered by the phosphor BoxLayout resizing an absolute-sized codemirror div - that's my current working hypothesis. |
jasongrout commentedMay 25, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
ian-r-rose commentedMay 25, 2018
Interestingly, I am seeing similar numbers to you on Chrome, but Firefox 60 ismuch faster on master. All with loading the file on Ubuntu 16.10: Chrome 64 (master/context): 20s/60s |
jasongrout commentedMay 25, 2018
With this patch on this branch (6749792), I get about 23s on load, 20s on tab activation: diff --git a/packages/docregistry/src/default.ts b/packages/docregistry/src/default.tsindex c54c7dd4b..dfe4e3fc7 100644--- a/packages/docregistry/src/default.ts+++ b/packages/docregistry/src/default.ts@@ -420,7 +420,7 @@ class DocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.IMode constructor(options: DocumentWidget.IOptions<T, U>) { // Include the context ready promise in the widget reveal promise- options.reveal = Promise.all([options.reveal, options.context.ready]);+ // options.reveal = Promise.all([options.reveal, options.context.ready]); super(options); this.context = options.context; |
ian-r-rose commentedMay 25, 2018
I can confirm I also see the speedup when commenting out that line. |
jasongrout commentedMay 25, 2018
With this patch instead (on6749792), I'm also seeing the faster 20s load time: diff --git a/packages/docregistry/src/default.ts b/packages/docregistry/src/default.tsindex c54c7dd4b..91f96bb06 100644--- a/packages/docregistry/src/default.ts+++ b/packages/docregistry/src/default.ts@@ -420,7 +420,8 @@ class DocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.IMode constructor(options: DocumentWidget.IOptions<T, U>) { // Include the context ready promise in the widget reveal promise- options.reveal = Promise.all([options.reveal, options.context.ready]);+ // options.reveal = Promise.all([options.reveal, options.context.ready]);+ options.reveal = Promise.resolve(); super(options); this.context = options.context; |
ian-r-rose commentedMay 25, 2018
Got to get you on Firefox, with these sweet 6 second loading times :) |
jasongrout commentedMay 25, 2018
I was thinking that having any promise was tripping the longer load time, but even when we do take the asynchronous route in the main area widget constructor, we still can get fast load times. Iam on ff - just when I was profiling I started using Chrome since it has way better debugging tools in general. |
jasongrout commentedMay 25, 2018
(and the vast majority of the populace uses Chrome, so we should make sure it works there too :). |
jasongrout commentedMay 25, 2018
Define the following utility functions in that docregistry/src/default.ts file: /** * Return a promise that resolves in the given milliseconds with the given value. */exportfunctionsleep<T>(milliseconds:number=0,value?:T):Promise<T>{returnnewPromise((resolve,reject)=>{setTimeout(()=>{resolve(value);},milliseconds);});}/** * Return a promise that resolves in the next animatino frame with the particular value. */exportfunctionmoment<T>(value?:T):Promise<T>{returnnewPromise((resolve,reject)=>{requestAnimationFrame(()=>{resolve(value);});});} Then making Current working hypothesis - if the editor value is set before the reveal promise is resolved, things are slow. If the editor value is set after the reveal promise is resolved, things are fast. |
ian-r-rose commentedMay 25, 2018
I think that CodeMirror may be having layout issues if the editor is not actually attached to the DOM. If I add the content widgetbefore the |
ian-r-rose commentedMay 25, 2018
That is to say, remove |
jasongrout commentedMay 25, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That was one of the next couple of things I was going to try. Thanks for the tip to shortcut the experiments! |
jasongrout commentedMay 25, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
More experiments... (a) If I attach the content and toolbar, it takes up some of the space and the spinner is pushed down. In some profiling, it seemed that the content focus was triggering a layout that was taking a long time. However, eliminating the focus call in the main area widget constructor on top of (b) still took a long time. |
ian-r-rose commentedMay 25, 2018
Hmmm, sounds like another div may be necessary. |
…than a full phosphor widget.We are seeing significant slowdowns opening large (megabytes) one-line code editor files, where it seems that setting the large text value before putting the codemirror on the page is drastically slowing things down. This approach puts the widget on the page immediately (thus avoiding the slowdown), and just covers it with a spinner until it can be revealed.
jasongrout commentedMay 25, 2018
I reverted back to using the spinner as just a DOM node, rather than treating it like a phosphor widget. This is a bit kludgy since you aren't supposed to mess around with a BoxLayout DOM node, but it works for now, and we can investigate more later. |
ian-r-rose commentedMay 25, 2018
That works for me. We could use a What prompted you to change your mind on whether |
ian-r-rose left a comment
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.
Looks great!
jasongrout commentedMay 25, 2018
Change in content being null was from it being easier to write the check, it being our common pattern, and thinking more about how disposing the content is linked to disposing the main widget. |
ian-r-rose commentedMay 25, 2018
Merging, as the appveyor issues are unrelated. Thanks@jasongrout! |
Uh oh!
There was an error while loading.Please reload this page.
This addresses multiple issues with the contexts and document manager, including#4443,#3495
.contentand.notebook. Perhaps deprecate.notebook?.notebookattribute of Notebook panels.jupyterlab/packages/docmanager/src/manager.ts
Lines 476 to 477 in473348d
Design discussions:
.contentattribute? See for example many places where for the file editor actions, we have to dowidget.content.editor.Don't push up attributes - let people go to.contentto interact with the content widget.