Skip to content

Share one compiler + Python runtime across all docs pages - #2

Merged
simontreanor merged 1 commit into
mainfrom
shared-runner
Jul 15, 2026
Merged

Share one compiler + Python runtime across all docs pages#2
simontreanor merged 1 commit into
mainfrom
shared-runner

Conversation

@simontreanor

Copy link
Copy Markdown
Owner

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.

…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
simontreanor merged commit 433bb9b into main Jul 15, 2026
10 checks passed
@simontreanor
simontreanor deleted the shared-runner branch July 15, 2026 16:46
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant