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

Better handling of slow kernel startup #8174

Merged
merged 3 commits into from
Apr 8, 2020

Conversation

blink1073
Copy link
Contributor

@blink1073 blink1073 commented Apr 5, 2020

References

#7403 #6007

See discussion in jupyter-server/jupyter_server#197 about the issues around slow starting kernels/terminals and a longer term solution.

While a slow kernel is starting, show it as being in "initializing" status with a filled circle and the name of the pending kernel. The user is now allowed to change the kernel while the previous session is starting. When a session is started, it shuts down an existing session so there is only one running session on the server.

We have to destroy an in-flight session connection rather than wait for it to finish. We properly shut down sessions that have been superseded. The classic notebook handles session restarts by destoying/creating, but does so synchronously. The user has to wait for the slow session to start before it switches. Classic notebook does not handle a change kernel request while the initial kernel is being created.

We use a unique id for the path when creating the session, and then change the path of the created session to the desired path. This is to avoid the race condition of when a session with a given path saves its state in the server database.

Note, I simulated slow kernels by adding a gen.sleep() in start_kernel.

I plan to backport this to 1.2.x since it involves no API changes and is a bug fix.

Slow start:
image

image

Switching during a slow start:
image

Selecting no kernel during a slow start:
image

Code changes

Add internal logic to session context to handle slow kernel behavior. Show filled icon for initializing status and in the toolbar. Update status bar handlers to always use display name and display status from the session context.

User-facing changes

Better indication of the status of slow starting kernels.

Backwards-incompatible changes

None

@blink1073 blink1073 added this to the 2.1 milestone Apr 5, 2020
@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@blink1073 blink1073 changed the title [WIP] Better handling of slow kernel startup Better handling of slow kernel startup Apr 6, 2020
@blink1073 blink1073 changed the title Better handling of slow kernel startup [WIP] Better handling of slow kernel startup Apr 6, 2020
@blink1073 blink1073 changed the title [WIP] Better handling of slow kernel startup Better handling of slow kernel startup Apr 6, 2020
@saulshanabrook saulshanabrook modified the milestones: 2.1, 2.2 Apr 6, 2020
@saulshanabrook
Copy link
Member

I am moving to the next milestone so we have some more discussion on this before merging, but seems reasonable!

@blink1073 blink1073 changed the title Better handling of slow kernel startup [WIP] Better handling of slow kernel startup Apr 7, 2020
@blink1073
Copy link
Contributor Author

I tried the resolve merge feature in Github. It results in a merge commit. I'll rebase and push.

Allow switching kernels while a session is initializing

Account for kernel switching

wip testing session context

Finish up logic and tests

Cleanup

Fix handling of No Kernel in switcher dialog

Fix handling of no kernel selected

Address review comments
@blink1073 blink1073 force-pushed the slow-kernel-indicator branch from 332519f to 179f8d1 Compare April 7, 2020 09:35
@blink1073 blink1073 changed the title [WIP] Better handling of slow kernel startup Better handling of slow kernel startup Apr 7, 2020
@blink1073 blink1073 changed the title Better handling of slow kernel startup [WIP] Better handling of slow kernel startup Apr 7, 2020
@blink1073 blink1073 changed the title [WIP] Better handling of slow kernel startup Better handling of slow kernel startup Apr 7, 2020
Copy link
Member

@afshin afshin left a comment

Choose a reason for hiding this comment

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

👍

@blink1073
Copy link
Contributor Author

@meeseeksdev please backport to 2.1.x

@lumberbot-app
Copy link

lumberbot-app bot commented Apr 24, 2020

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout 2.1.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 44f161b1025acb1948599effdf55b28dcd9693c5
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #8174: Better handling of slow kernel startup'
  1. Push to a named branch :
git push YOURFORK 2.1.x:auto-backport-of-pr-8174-on-2.1.x
  1. Create a PR against branch 2.1.x, I would have named this PR:

"Backport PR #8174 on branch 2.1.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

@jupyterlab jupyterlab deleted a comment from lumberbot-app bot Apr 24, 2020
@github-actions github-actions bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg:apputils pkg:statusbar status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. tag:Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants