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

Run kernel on cell execution when no kernel #12858

Merged

Conversation

a3626a
Copy link
Contributor

@a3626a a3626a commented Jul 26, 2022

Background

There are several requests about opening notebook file without kernel. KernelPreference already have shouldStart boolean flag. This flag can be set through jupyter server argument --LabServerApp.notebook_starts_kernel=False. This flag works as intended, so it prevents kernels to be launched automatically.

Nevertheless, we need more improvement here. When users execute a code cell in a notebook without kernel, it shows a dialog:
image
(It was done by this PR #12379)
When shouldStart is false, user must select kernels for every notebook file opened. It is very annoying, and bad user experience.

So I suggest a new behaviors for launching a new kernel on code execution.

  • Requirement A: Automatically selects kernel if possible
  • Requirement B: Keep executing code after starting the kernel
    • or select the kernel (and start).

References

This closes #12793 as it set the autoStartDefault.

Code changes

SessionContext

  • Extract kernel start logic from _startIfNecessary into a new public method startKernel
  • Loose restriction for getDefaultKernel
    • don't care about shouldStart
      • it is backwards-incompatible changes, but I think backwards-compatible changes are possible. Help needed
    • startKernel depends on getDefaultKernel to automatically select a kernel.
  • SessionContextDialogs default global are removed - you should use the token '@jupyterlab/apputils-extension:sessionDialogs' (This is a similar change to the sanitizer or the content factory to be more token based)
  • To be able to set autoStartDefault only for notebook (with a settings in notebook-extension package) with a check box in the kernel selection dialog, the logic is a complex. But basically, if autoStartDefault is not undefined a checkbox will be displayed. The checkbox value will be used to update the session context kernel preference. That update will trigger a new kernelPreferenceChanged in ISessionContext. That signal is listen to in the notebook extension to be able to update the settings.

Actions

  • runCell
    • if no kernel, call startKernel
      • it satisfies Requirement A
    • work on promise to satisfy Requirement B

User-facing changes

When a notebook is opened without kernel and a user tries to execute a code cell, the user don't have to select a kernel. Additionally, code is executed immediately after the kernel executed.

When the user is opening a new notebook, if the new settings is true, the associated kernel will be started directly.

Before (JLab 4.0.0a34)

jlab400a34

After

thispr

Backwards-incompatible changes

global sessionContextDialogs from @jupyterlab/apputils does not exist any longer.

In my initial draft, the semantic of getDefaultKernel changed. It is not a serious but a backwards-incompatible change. I think it is possible to satify Requirement A without editing getDefaultKernel, but some level of code duplication is inevitable.

I need help to choose the direction, 1) ignoring small level of backwards-incompatibility or 2) accepting a little bit of duplication.

(Edited) getDefaultKernel is a private function. I made every function which calls Private.getDefaultKernel keep old behavior.

@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@a3626a
Copy link
Contributor Author

a3626a commented Oct 28, 2022

I have found that getDefaultKernel is a private function (is located inside Privte namespace) So this is not a backward incompatible change. I think this PR is OK to be merged.

@a3626a a3626a marked this pull request as ready for review October 28, 2022 00:54

// Always fall back to selecting a kernel
return true;
return this.startKernel();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_startIfNecessary already checked preference.shouldStart === false So _startIfNecessary is backward compatible

Comment on lines +1280 to +1311
const { preference } = options;
const { shouldStart } = preference;

if (shouldStart === false) {
return null;
}

Copy link
Contributor Author

@a3626a a3626a Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to make SessionContext.getDefaultKernel be backward compatible.


Honestly, I don't like this change... It is very hard to understand this code without knowing history.


Previous code is very simple, but it is not straightforward, too. Why Private.getDefaultKernel is needed? We already opened Private.getDefaultKernel by SessionContext.getDefaultKernel.

Comment on lines 2205 to 2268
if (sessionContext.hasNoKernel) {
void sessionContextDialogs.selectKernel(sessionContext);
return Promise.resolve(false);
}
const deletedCells = notebook.model?.deletedCells ?? [];
executionScheduled.emit({ notebook, cell });
return CodeCell.execute(cell as CodeCell, sessionContext, {
deletedCells,
recordTiming: notebook.notebookConfig.recordTiming
})
.then(reply => {
deletedCells.splice(0, deletedCells.length);
if (cell.isDisposed) {
return false;
promise = sessionContext.startKernel().then(shouldSelect => {
if (shouldSelect) {
return sessionContextDialogs.selectKernel(sessionContext);
}
});
}
Copy link
Contributor Author

@a3626a a3626a Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we conditionally chain a promise to start new default kernel or prompt dialogs.

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not looking at this earlier and thanks a lot for the PR. I understand and like the idea. But some organization prefer to be able to pick a kernel. Recently the dialog has been extended to display a checkbox in the footer: see documentation.

Do you think it could be possible to use it on the kernel dialog selection to add an option Always select the preferred kernel? That will be stored in a settings in order to allow your use case A or not. And in your deployed installation, that settings could be set to true to fit your need.

@a3626a
Copy link
Contributor Author

a3626a commented Dec 30, 2022

@fcollonval

Sorry for not looking at this earlier and thanks a lot for the PR. I understand and like the idea. But some organization prefer to be able to pick a kernel. Recently the dialog has been extended to display a checkbox in the footer: see documentation.

Do you think it could be possible to use it on the kernel dialog selection to add an option Always select the preferred kernel? That will be stored in a settings in order to allow your use case A or not. And in your deployed installation, that settings could be set to true to fit your need.

Sorry for my late reply. Your suggestion about checkbox is good.

For the first, I added new configurable setting selectPrefferedKernel. But updating setting by clicking checkbox is more complicated, it is not done, yet. I am checking confirmClosingDocument related codes.


I'm now considering using commands for turning on the selectPrefferedKernel.
First I defined a command like this.

      commands.addCommand(CommandIDs.setSelectPreferredKernel, {
        label: trans.__('Auto Select The Preferred Kernel'),
        execute: args => {
          void settings.set('selectPreferredKernel', true);
        }
      });

Then I will add checkbox and execute the command here:

async selectKernel(
sessionContext: ISessionContext,
translator?: ITranslator
): Promise<void> {
if (sessionContext.isDisposed) {
return Promise.resolve();
}
translator = translator || nullTranslator;
const trans = translator.load('jupyterlab');
// If there is no existing kernel, offer the option
// to keep no kernel.
let label = trans.__('Cancel');
if (sessionContext.hasNoKernel) {
label = sessionContext.kernelDisplayName;
}
const buttons = [
Dialog.cancelButton({ label }),
Dialog.okButton({ label: trans.__('Select') })
];
const dialog = new Dialog({
title: trans.__('Select Kernel'),
body: new Private.KernelSelector(sessionContext, translator),
buttons
});
const result = await dialog.launch();
if (sessionContext.isDisposed || !result.button.accept) {
return;
}
const model = result.value;
if (model === null && !sessionContext.hasNoKernel) {
return sessionContext.shutdown();
}
if (model) {
await sessionContext.changeKernel(model);
}
},

Unfortunately, CommandRegistry is not available. Also I think passing CommandRegistry to SessionContext, Notebook, ... is a bad for this small feature. Is there any advice?

@fcollonval
Copy link
Member

Hey sorry too for the slow reply. My two cents here is that we should drop the default sessionContextDialogs object and only allow to get them through the token.

So the actions are:

  1. at that line, we should instantiate and return the session dialogs.

return sessionContextDialogs;

  1. Replace that constant object by a class

export const sessionContextDialogs: ISessionContext.IDialogs = {

It will take the translator: ITranslator object - so we can drop it from SessionContext.IOptions.

  1. Add an attribute selectPreferredKernel to that class.

  2. Pass to the new class the settings: ISettingsRegistry.ISettings . Use it to get selectPreferredKernel and to save it when it is set to a different value.

  3. Modify the dialog to bypass it or not depending of selectPreferredKernel and add a checkbox to set selectPreferredKernel depending of the checkbox status.

Does it make sense?

@a3626a
Copy link
Contributor Author

a3626a commented Jan 19, 2023

Hey sorry too for the slow reply. My two cents here is that we should drop the default sessionContextDialogs object and only allow to get them through the token.

So the actions are:

  1. at that line, we should instantiate and return the session dialogs.

return sessionContextDialogs;

  1. Replace that constant object by a class

export const sessionContextDialogs: ISessionContext.IDialogs = {

It will take the translator: ITranslator object - so we can drop it from SessionContext.IOptions.

  1. Add an attribute selectPreferredKernel to that class.
  2. Pass to the new class the settings: ISettingsRegistry.ISettings . Use it to get selectPreferredKernel and to save it when it is set to a different value.
  3. Modify the dialog to bypass it or not depending of selectPreferredKernel and add a checkbox to set selectPreferredKernel depending of the checkbox status.

Does it make sense?

I finally understand what Token is. It is actually a Dependency Injection system. Thank you for your reply, it helps a lot.


It will take the translator: ITranslator object - so we can drop it from SessionContext.IOptions

Should translator be dropped in this PR? It will make this PR not backward compatible.

@fcollonval
Copy link
Member

Should translator be dropped in this PR? It will make this PR not backward compatible.

Indeed this is a good point - we can keep it to ease backporting it.

@a3626a
Copy link
Contributor Author

a3626a commented Jan 19, 2023

I have finished dropping old default sessionContextDialogs. And I found that it is somewhat impossible to make it backward compatible. So many functions have to be changed. To make it compatible, We should keep old default.

I will check tests now. It looks like Github actions are failing with some other reason during installation.


2023-01-19.20-24-30.mp4

packages/apputils/src/sessioncontext.tsx Outdated Show resolved Hide resolved
packages/apputils/src/sessioncontext.tsx Outdated Show resolved Hide resolved
@fcollonval fcollonval force-pushed the feature/run-kernel-on-execute branch from 18d8381 to 99ee80d Compare March 15, 2023 16:01
@fcollonval fcollonval merged commit a8225e5 into jupyterlab:master Mar 16, 2023
@fcollonval fcollonval deleted the feature/run-kernel-on-execute branch March 16, 2023 14:17
@github-actions
Copy link
Contributor

Benchmark report

The execution time (in milliseconds) are grouped by test file, test type and browser.
For each case, the following values are computed: min <- [1st quartile - median - 3rd quartile] -> max.

The mean relative comparison is computed with 95% confidence.

Results table
Test file large_code_notebook large_md_notebook
open
chromium
actual 585 <- [643 - 666 - 689] -> 736 712 <- [1220 - 1246 - 1286] -> 1404
expected 583 <- [628 - 655 - 679] -> 905 1153 <- [1221 - 1243 - 1270] -> 1432
Mean relative change ⚠️ 1.3% ± 1.6% -0.4% ± 1.5%
switch-from
chromium
actual 621 <- [672 - 699 - 722] -> 815 269 <- [318 - 353 - 384] -> 451
expected 590 <- [672 - 686 - 705] -> 957 264 <- [318 - 350 - 379] -> 498
Mean relative change ⚠️ 1.0% ± 1.6% 1.3% ± 3.4%
switch-to
chromium
actual 1144 <- [1230 - 1242 - 1265] -> 1437 780 <- [837 - 851 - 869] -> 922
expected 1102 <- [1218 - 1237 - 1252] -> 1497 776 <- [842 - 856 - 874] -> 944
Mean relative change ⚠️ 1.0% ± 1.0% -0.9% ± 0.9%
close
chromium
actual 139 <- [152 - 158 - 168] -> 195 210 <- [238 - 251 - 270] -> 294
expected 142 <- [152 - 156 - 162] -> 204 211 <- [242 - 252 - 266] -> 316
Mean relative change ⚠️ 1.7% ± 2.0% -0.5% ± 2.2%

Changes are computed with expected as reference.

@jupyterlab/benchmarks@1.0.0 test:mocha
mocha ./tests/

Waiting for localhost:8888
localhost:8888 is up

Cell memory leaks

Create a code cell Memory change: -158 kB Leak detected: No

Leaking objects:

Object # added Retained size increase
ArraySearchMarker 1 +5 B
ContentDeleted 1 +16 B
ContentString 1 +66 B
Detached Text 1 +71 B
FocusTracker 1 +276 B
ObservableList 1 +172 B
OutputArea 1 +1.43 kB
OutputAreaModel 1 +183 B
Promise 1 +20 B
PromiseDelegate 1 +128 B
ResizeHandle 1 +47 B
RestorablePool 1 +558 B
UndoManager 1 +1.93 kB
WidgetTracker 1 +1.05 kB
YArray 1 +164 B
YCodeCell 1 +107 B
YText 1 +46 B
Detached DOMStringMap 2 +88 B
Detached V8EventHandlerNonNull 2 +80 B
Set 2 +1.42 kB
YMap 2 +464 B
StackItem 3 +1.32 kB
ContentAny 4 +235 B
ContentType 4 +64 B
DeleteItem 4 +80 B
DeleteSet 6 +988 B
Detached HTMLCollection 6 +560 B
EventHandler 8 +256 B
ID 10 +320 B
Item 10 +1.2 kB
Detached DOMTokenList 13 +808 B
Detached Attr 14 +1.01 kB
Detached HTMLDivElement 14 +46.7 kB
Map 17 +11.1 kB
Signal 19 +319 B
Object 35 +188 kB
Array 44 +25.4 kB
Detached V8EventListener 263 +23.4 kB
Detached EventListener 265 +42.6 kB
(closure) 270 +975 B
Detached InternalNode 323 +45.1 kB

Leaking collections:

Type Change Preview Size increased at
Array +2 [StackItem, ...]
UndoManager.afterTransactionHandler  http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:5030:15
webpack://jupyterlab/node_modules/lib0/observable.js:73:62
Array.forEach <anonymous>
webpack://jupyterlab/node_modules/lib0/observable.js:73:62
Array.<anonymous> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4693:27
webpack://jupyterlab/node_modules/lib0/function.js:19:0
cleanupTransactions http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4695:62
transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4810:9
Doc.transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:2023:5
Array +10 [Item, ...]
addStruct                    http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4268:11
Item.integrate http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:11054:7
<unknown> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6617:22
Array.forEach <anonymous>
typeListInsertGenericsAfter http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6590:11
typeListInsertGenerics http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6677:10
<unknown> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6996:9
transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4796:5
YArray.insert http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6995:7
Set +1 Set((anonymous function), ...)
                          webpack://jupyterlab/node_modules/lib0/observable.js:30:56                                                                                     
Doc.on http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:2182:11
new UndoManager http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:5050:14
YCodeCell.setUndoManager http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:398:33
<unknown> http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1584:15
Array.forEach <anonymous>
YNotebook.insertCells http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1583:16
YNotebook.insertCell http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1564:21
webpack://jupyterlab/packages/notebook/src/actions.tsx:404:22
Create a markdown cell Memory change: -104 kB Leak detected: No

Leaking objects:

Object # added Retained size increase
ActivityMonitor 1 +294 B
ArraySearchMarker 1 +5 B
AttachmentsModel 1 +193 B
AttachmentsResolver 1 +14 B
CodeCellModel 1 +359 B
ContentString 1 +69 B
Debouncer 1 +3.46 kB
Detached HTMLAnchorElement 1 +308 B
Detached HTMLButtonElement 1 +5.31 kB
Detached HTMLHeadingElement 1 +1 kB
Error 1 +3.06 kB
MarkdownCell 1 +4.73 kB
MarkdownCellModel 1 +237 B
Poll 1 +3.7 kB
RenderMimeRegistry 1 +227 B
RenderedMarkdown 1 +65 B
Transaction 1 +860 B
TypeError 1 +295 B
YArray 1 +164 B
YArrayEvent 1 +357 B
YCodeCell 1 +107 B
YMarkdownCell 1 +45 B
Detached CSSStyleDeclaration 2 +116 B
Detached HTMLElement 2 +320 B
Detached V8EventHandlerNonNull 2 +5.04 kB
Promise 2 +3.06 kB
PromiseDelegate 2 +3.27 kB
UndoManager 2 +2.38 kB
YText 2 +490 B
Detached DOMStringMap 3 +128 B
ObservableMap 3 +381 B
StackItem 3 +1.33 kB
DeleteItem 4 +80 B
YMap 4 +872 B
ContentAny 5 +454 B
DeleteSet 6 +1 kB
ContentType 7 +112 B
Detached Text 7 +504 B
Set 8 +1.76 kB
Detached HTMLDivElement 10 +30.4 kB
Detached DOMTokenList 13 +796 B
ID 13 +416 B
Item 13 +1.72 kB
EventHandler 14 +459 B
Detached HTMLCollection 17 +1.75 kB
Map 27 +12.1 kB
Signal 28 +722 B
Detached V8EventListener 130 +10.9 kB
Detached EventListener 132 +25.5 kB
(closure) 152 +14.9 kB
Detached InternalNode 162 +28.2 kB

Leaking collections:

Type Change Preview Size increased at
Array +1 [{signal, slot, thisArg}, ...]
Object.connect  http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10490:17
Signal.connect http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10230:24
webpack://jupyterlab/packages/notebook/src/notebooktools.ts:226:33
invokeSlot http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10699:18
Object.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10657:17
Signal.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10256:17
webpack://jupyterlab/packages/notebook/src/tracker.ts:90:30
invokeSlot http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10699:18
Object.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10657:17
Array +1 [{signal, slot, thisArg}, ...]
Object.connect  http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10490:17
Signal.connect http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10230:24
webpack://jupyterlab/packages/cell-toolbar/src/celltoolbartracker.ts:121:37
invokeSlot http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10699:18
Object.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10657:17
Signal.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10256:17
webpack://jupyterlab/packages/notebook/src/widget.ts:1321:30
webpack://jupyterlab/packages/notebook/src/actions.tsx:408:28
webpack://jupyterlab/packages/notebook-extension/src/index.ts:2719:15
Array +1 [2bdf7273-e94a-4281-9992-6a6c3232bf83, ...]
                                     webpack://jupyterlab/packages/notebook/src/actions.tsx:2503:37            
Array.forEach <anonymous>
webpack://jupyterlab/packages/notebook/src/actions.tsx:2498:21
webpack://jupyterlab/packages/notebook/src/actions.tsx:350:12
webpack://jupyterlab/packages/notebook-extension/src/index.ts:2650:15
CommandRegistry.execute http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:5748:33
CommandRegistry._executeKeyBinding http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:5906:14
CommandRegistry.processKeydownEvent http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:5846:18
JupyterLab.evtKeydown http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:4660:23
Array +2 [StackItem, ...]
UndoManager.afterTransactionHandler  http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:5030:15
webpack://jupyterlab/node_modules/lib0/observable.js:73:62
Array.forEach <anonymous>
webpack://jupyterlab/node_modules/lib0/observable.js:73:62
Array.<anonymous> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4693:27
webpack://jupyterlab/node_modules/lib0/function.js:19:0
cleanupTransactions http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4695:62
transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4810:9
Doc.transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:2023:5
Array +13 [Item, ...]
addStruct                    http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4268:11
Item.integrate http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:11054:7
<unknown> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6617:22
Array.forEach <anonymous>
typeListInsertGenericsAfter http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6590:11
typeListInsertGenerics http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6677:10
<unknown> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6996:9
transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4796:5
YArray.insert http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6995:7
Set +2 Set((anonymous function), ...)
                          webpack://jupyterlab/node_modules/lib0/observable.js:30:56                                                                                     
Doc.on http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:2182:11
new UndoManager http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:5050:14
YCodeCell.setUndoManager http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:398:33
<unknown> http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1584:15
Array.forEach <anonymous>
YNotebook.insertCells http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1583:16
YNotebook.insertCell http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1564:21
webpack://jupyterlab/packages/notebook/src/actions.tsx:404:22
Create a raw cell Memory change: -154 kB Leak detected: No

Leaking objects:

Object # added Retained size increase
ArraySearchMarker 1 +5 B
CodeCellModel 1 +359 B
ContentString 1 +690 B
Detached CSSStyleDeclaration 1 +64 B
Detached V8EventHandlerNonNull 1 +40 B
ObservableMap 1 +109 B
TypeError 1 +301 B
YArray 1 +164 B
YCodeCell 1 +107 B
YRawCell 1 +45 B
Detached DOMStringMap 2 +100 B
Set 2 +1.31 kB
UndoManager 2 +2.38 kB
YText 2 +561 B
StackItem 3 +1.33 kB
DeleteItem 4 +80 B
YMap 4 +872 B
ContentAny 5 +524 B
Detached HTMLCollection 5 +476 B
DeleteSet 6 +1 kB
ContentType 7 +112 B
Detached DOMTokenList 9 +628 B
Detached HTMLDivElement 9 +22.6 kB
Signal 11 +450 B
ID 13 +416 B
Item 13 +2.41 kB
EventHandler 14 +459 B
Map 19 +11.6 kB
Detached V8EventListener 130 +10.9 kB
Detached EventListener 131 +20.4 kB
(closure) 140 +13.2 kB
Detached InternalNode 151 +21.7 kB

Leaking collections:

Type Change Preview Size increased at
Array +1 [88ae9a79-91c5-43f0-bcd0-e8e98fb65b8b, ...]
                                     webpack://jupyterlab/packages/notebook/src/actions.tsx:2503:37            
Array.forEach <anonymous>
webpack://jupyterlab/packages/notebook/src/actions.tsx:2498:21
webpack://jupyterlab/packages/notebook/src/actions.tsx:350:12
webpack://jupyterlab/packages/notebook-extension/src/index.ts:2650:15
CommandRegistry.execute http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:5748:33
CommandRegistry._executeKeyBinding http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:5906:14
CommandRegistry.processKeydownEvent http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:5846:18
JupyterLab.evtKeydown http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:4660:23
Array +1 [{signal, slot, thisArg}, ...]
Object.connect  http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10490:17
Signal.connect http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10230:24
webpack://jupyterlab/packages/cell-toolbar/src/celltoolbartracker.ts:121:37
invokeSlot http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10699:18
Object.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10657:17
Signal.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10256:17
webpack://jupyterlab/packages/notebook/src/widget.ts:1321:30
webpack://jupyterlab/packages/notebook/src/actions.tsx:408:28
webpack://jupyterlab/packages/notebook-extension/src/index.ts:2719:15
Array +1 [{signal, slot, thisArg}, ...]
Object.connect  http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10490:17
Signal.connect http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10230:24
webpack://jupyterlab/packages/notebook/src/notebooktools.ts:226:33
invokeSlot http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10699:18
Object.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10657:17
Signal.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10256:17
webpack://jupyterlab/packages/notebook/src/tracker.ts:90:30
invokeSlot http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10699:18
Object.emit http://localhost:8888/static/lab/jlab_core.e1a913e5a1839ee16b95.js:10657:17
Array +2 [StackItem, ...]
UndoManager.afterTransactionHandler  http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:5030:15
webpack://jupyterlab/node_modules/lib0/observable.js:73:62
Array.forEach <anonymous>
webpack://jupyterlab/node_modules/lib0/observable.js:73:62
Array.<anonymous> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4693:27
webpack://jupyterlab/node_modules/lib0/function.js:19:0
cleanupTransactions http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4695:62
transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4810:9
Doc.transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:2023:5
Array +13 [Item, ...]
addStruct                    http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4268:11
Item.integrate http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:11054:7
<unknown> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6617:22
Array.forEach <anonymous>
typeListInsertGenericsAfter http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6590:11
typeListInsertGenerics http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6677:10
<unknown> http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6996:9
transact http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:4796:5
YArray.insert http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:6995:7
Set +2 Set((anonymous function), ...)
                          webpack://jupyterlab/node_modules/lib0/observable.js:30:56                                                                                     
Doc.on http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:2182:11
new UndoManager http://localhost:8888/static/lab/vendors-node_modules_yjs_dist_yjs_mjs.4fbeace2166db933a6e2.js:5050:14
YCodeCell.setUndoManager http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:398:33
<unknown> http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1584:15
Array.forEach <anonymous>
YNotebook.insertCells http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1583:16
YNotebook.insertCell http://localhost:8888/static/lab/vendors-node_modules_jupyter_ydoc_lib_index_js-node_modules_process_browser_js.fc8babfba933ff460960.js:1564:21
webpack://jupyterlab/packages/notebook/src/actions.tsx:404:22
- Drag and drop a cell

File editor memory leaks

Create a file Memory change: -74.5 kB Leak detected: No

Leaking objects:

Object # added Retained size increase
Detached HTMLUListElement 1 +3.11 kB
Detached V8EventHandlerNonNull 1 +40 B
VirtualElementPass 1 +46 B
Detached HTMLButtonElement 2 +23.7 kB
Detached SVGCircleElement 2 +1.1 kB
LabIcon 2 +1.07 kB
Detached CSSStyleDeclaration 3 +228 B
Detached HTMLLIElement 3 +5.88 kB
Detached NodeList 3 +204 B
NavigationHistoryEntry 3 +720 B
VirtualText 3 +109 B
Detached SVGGElement 4 +2.94 kB
VirtualElement 4 +2.18 kB
Detached SVGAnimatedPreserveAspectRatio 5 +320 B
Detached SVGAnimatedRect 5 +320 B
Detached SVGPathElement 5 +1.77 kB
Detached SVGSVGElement 5 +8.02 kB
Detached HTMLSpanElement 6 +2.28 kB
Detached DOMStringMap 7 +420 B
Detached SVGAnimatedNumber 7 +448 B
Detached Attr 10 +720 B
Detached Text 10 +912 B
Detached HTMLCollection 13 +1.42 kB
Detached DOMTokenList 14 +916 B
Detached HTMLDivElement 15 +33.5 kB
Detached SVGAnimatedString 16 +896 B
Detached SVGAnimatedTransformList 16 +1.02 kB
Detached SVGAnimatedLength 26 +1.66 kB
Array 42 +24.7 kB
Detached V8EventListener 130 +10.9 kB
Detached EventListener 131 +20.4 kB
(closure) 138 +20.3 kB
✔ Opening a text file (67740ms)

Notebook memory leaks

Create a notebook Memory change: +26.6 kB Leak detected: Yes

Leaking objects:

Object # added Retained size increase
Detached HTMLUListElement 1 +2.22 kB
Detached V8EventHandlerNonNull 1 +40 B
VirtualElementPass 1 +61 B
Detached HTMLButtonElement 2 +23.4 kB
Detached SVGCircleElement 2 +1.1 kB
HTMLDivElement 2 +14 B
LabIcon 2 +931 B
Detached CSSStyleDeclaration 3 +236 B
Detached HTMLLIElement 3 +5.97 kB
Detached NodeList 3 +216 B
NavigationHistoryEntry 3 +720 B
VirtualText 3 +109 B
VirtualElement 4 +1.09 kB
Detached SVGAnimatedPreserveAspectRatio 5 +320 B
Detached SVGAnimatedRect 5 +320 B
Detached SVGSVGElement 5 +9.29 kB
Detached HTMLSpanElement 6 +3.09 kB
Detached SVGGElement 6 +4.9 kB
Detached SVGPathElement 7 +2.47 kB
Detached SVGAnimatedNumber 9 +576 B
Detached Attr 10 +720 B
Detached Text 10 +696 B
Detached HTMLCollection 13 +1.35 kB
Detached DOMTokenList 15 +1.04 kB
Detached HTMLDivElement 15 +33.2 kB
Detached SVGAnimatedString 20 +1.12 kB
Detached SVGAnimatedTransformList 20 +1.28 kB
Detached SVGAnimatedLength 26 +1.66 kB
Detached V8EventListener 130 +10.9 kB
Detached EventListener 131 +20.4 kB
(closure) 139 +30.4 kB
✔ Opening a notebook (71225ms)

2 passing (6m)
1 pending
1 failing

   Adding a cell:

  Create a code cell - Objects leaking
  + expected - actual

  -1357
  +1308
  
  at file:///home/runner/work/_actions/jupyterlab/benchmarks/v1/memory-leaks/tests/utils.mjs:43:16
  at Array.forEach (<anonymous>)
  at expectNoLeaks (file:///home/runner/work/_actions/jupyterlab/benchmarks/v1/memory-leaks/tests/utils.mjs:28:11)
  at testScenario (file:///home/runner/work/_actions/jupyterlab/benchmarks/v1/memory-leaks/tests/utils.mjs:230:3)
  at async Context.<anonymous> (file:///home/runner/work/_actions/jupyterlab/benchmarks/v1/memory-leaks/tests/cell.test.mjs:7:5)

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

Successfully merging this pull request may close these issues.

None yet

4 participants