Repository navigation
Web app starts in ~7 s instead of ~11 s; first plot ~4 s sooner (D4.1) - #51
Merged
Merged
Conversation
Measured the start-up (scripts/web/boot_timing.js, a timeline from stlite's progress events now kept in window.eaglePlotBootLog) and cut the two big costs, locally with self-hosted Pyodide: - scipy is no longer loaded at start-up (it alone added ~2 s). Home starts loading it in the background (runtime.DEFERRED_PACKAGES); pages that import it show "Loading the science libraries..." until the load has settled (a settled promise, not find_spec: half-loaded scipy failed with "dynamic module does not define module export function"). Home and Quick Plot don't wait. - Home no longer imports pandas (~2.3 s under Pyodide): eagleplot.utils loads its submodules on first use (PEP 562) and session_state imports numpy/pandas where used. After Home is drawn, pandas, matplotlib and the plotting modules are imported in the background, one per loop turn. - eagleplot.plotting imports seaborn and plotly on first use (HAS_SEABORN / HAS_PLOTLY via find_spec), so a Matplotlib plot needs neither, nor scipy. Ready: 11.4 s -> 7.2 s. Home -> "Plot this example" -> plot, clicked at once: ~16.4 s -> 12.3 s from opening the app. docs.yml reports the start-up timeline with the real CDN on every run (non-gating). Tests: tests/test_web_build.py (deferred load, the waiting page, Quick Plot not waiting, no pandas in Home's imports, no seaborn/ plotly/scipy in eagleplot.plotting's). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
This is roadmap D4.1. I measured where the browser app's start-up goes, then cut the two biggest costs.
Measuring
index.htmlkeeps a start-up timeline inwindow.eaglePlotBootLog: each stlite progress message,loadFinishedand "ready".scripts/web/boot_timing.jsloads the app in a fresh browser profile (a first visit), then reloads with the cache kept (a warm visit). It prints the timeline and the bytes downloaded, including what the Python worker fetches.--throttleemulates a slower network.docs.ymlnow runs it after the smoke test, against the real Pyodide CDN, and writes the result to the job summary. It doesn't gate.Before, measured locally with self-hosted Pyodide (no network):
import pandasis 2.3 sWhat changed
runtime.DEFERRED_PACKAGES).find_spec. In testing, scipy's files were found before its compiled modules were loaded, and the page failed with "dynamic module does not define module export function".eagleplot.utilsloads its submodules on first use (PEP 562), andsession_stateimports numpy and pandas only inside the functions that use them.eagleplot.plottingimports seaborn and plotly on first use.HAS_SEABORNandHAS_PLOTLYnow come fromfind_spec, so a Matplotlib plot loads neither, nor scipy. This also speeds up the installed GUI slightly.Results (local, self-hosted Pyodide)
Download size: a cold start transfers about 64 MB compressed. 14 MB of that is scipy, which now loads after "ready". The biggest remaining items are pyarrow (10 MB, needed by Streamlit) and plotly (10 MB). Deferring plotly is the next step: Streamlit only registers its plotly theme when Streamlit starts, so that needs separate handling.
Tests
tests/test_web_build.pycovers:eagleplot.plottingnot loading seaborn, plotly or scipyscripts/web/smoke.jspasses, with 32 page loads including Data Upload right after start-up, the splash steps and the on-click download.🤖 Generated with Claude Code