liveplot.warm(): keep a render process ready so plots appear immediately - #12
Merged
Merged
Conversation
info-arena
added this pull request to stack #13
September 17, 2026 18:52
A plot's first frame waited ~0.75 s for its render process, almost all of it a fresh Python importing matplotlib. The render worker now does that warm-up first and then waits for its configuration, so a process can be started before any plot exists. warm() starts one; each LivePlot adopts the waiting process and a replacement starts in the background. Opt-in: without warm() nothing changes and no process is left behind. Measured in a real kernel, three plots in a row with a 2 s gap between cells: first frame 0.72-0.78 s cold, 0.21-0.24 s with warm(). The demo's setup cell calls it; the guide and API pages document it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G9zs684RFxHvW6cNWqTPSF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example
What
A plot's first frame used to wait ~0.75 s for its render process, and nearly all of that is a fresh Python importing matplotlib (process start 0.04 s, import and figure 0.55 s, first draw 0.05 s). The render worker now does that warm-up first and then waits for its configuration, so a process can be started before any plot exists.
liveplot.warm()starts one. EachLivePlotadopts the waiting process and a replacement starts in the background, so every later plot is fast too. It's opt-in: withoutwarm()nothing changes and no process is kept. The spare ignores interrupts and exits when the kernel dies, like the renderer always has.The tour's setup cell (
examples/demo.py) now calls it, and the guide and API pages document it.Measured
In a real kernel via nbclient, three plots in a row with a 2 s gap between cells (someone reading the notebook):
warm()warm()If cells run back to back with no gap, a plot can adopt a replacement that is still warming up and gets part of the benefit (measured 0.59 s).
No demo GIF: a recording starts at the first frame, so the wait this removes can't be seen in one; the table is the evidence.
Verified
tests/test_warm.py:warm()is exported and idempotent; a plot adopts the spare and a replacement starts; the warm first frame is under 0.4 s; a dead spare is replaced rather than used; an unused spare exits when its parent dies; and withoutwarm()plots leave no process behind. Full suite: 39 passed. The tour runs end to end as a script; the site builds strict-clean.Stacked on #11.
🤖 Generated with Claude Code
https://claude.ai/code/session_01G9zs684RFxHvW6cNWqTPSF