Share one compiler + Python runtime across all docs pages - #2
Merged
Conversation
…background The runnable-block worker is now a SharedWorker where supported (dedicated per-page worker as fallback, with in-flight replay if shared mode errors), so open tabs and the playground share a single live compiler and Pyodide instance; runs serialize inside the worker since pages share one interpreter. A SharedWorker still dies with its last page, so a same-tab navigation restarts it: for visitors who have used Run before (a localStorage flag), every page now warms the worker in the background at load, and the runtime is ready by the time they click. The docs widget also compiles inside the worker now, so lesson pages load no WASM on the main thread at all. Measured on lesson pages: first-ever run ~6.6s with the honest progress message; after a same-tab navigation ~1.0s (was ~6.3s); second tab ~0.6s; same-page rerun ~0.8s.
simontreanor
added a commit
that referenced
this pull request
Jul 16, 2026
…background (#2) The runnable-block worker is now a SharedWorker where supported (dedicated per-page worker as fallback, with in-flight replay if shared mode errors), so open tabs and the playground share a single live compiler and Pyodide instance; runs serialize inside the worker since pages share one interpreter. A SharedWorker still dies with its last page, so a same-tab navigation restarts it: for visitors who have used Run before (a localStorage flag), every page now warms the worker in the background at load, and the runtime is ready by the time they click. The docs widget also compiles inside the worker now, so lesson pages load no WASM on the main thread at all. Measured on lesson pages: first-ever run ~6.6s with the honest progress message; after a same-tab navigation ~1.0s (was ~6.3s); second tab ~0.6s; same-page rerun ~0.8s.
This was referenced Jul 31, 2026
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.
SharedWorker-backed runner (with per-page fallback), background warm-up for returning users, worker-side compilation for docs pages. Same-tab navigation Run time drops from ~6.3s to ~1.0s; cross-tab to ~0.6s.