[charts] POC: async scatter pipeline with skeleton#22366
Closed
JCQuintas wants to merge 1 commit into
Closed
Conversation
Architecture spike for KR1 (worker series prep). Three pieces: - scatterWorker.ts: receives a Float64 (x,y) buffer + viewport metrics, computes the linear scale, and returns SVG path strings. Runs the full scatter pipeline (extremums + mapping + path build) off the main thread. - AsyncScatter.tsx: experimental React component that renders a skeleton (border + "loading" placeholder) while the worker is busy, then swaps in the full <path> elements when the worker returns. Uses Transferable to ship the buffer (zero-copy out). - AsyncScatter.bench.tsx: pits this against ScatterChart at 100k and 1M. Bench at 800x400 (chromium): - 100k async first paint (skeleton): 6ms - 100k async full paint: 115ms - 100k sync ScatterChart full paint: 1076ms (9x slower) - 1M async first paint (skeleton): 22ms - 1M async full paint: 1258ms - 1M sync ScatterChart full paint: 12599ms (10x full / 570x first paint) Caveat: the comparison conflates two effects — bypassing the lib ChartProvider pipeline AND running off the main thread. Production integration would still wear the ChartProvider tax. Even so, the skeleton + worker pattern is clearly the right shape for the "responsive while loading" UX target. Open questions for productionisation: 1. Public API: per-chart `processInWorker` flag? Auto-trigger above threshold? How to expose for users who already have Float64 data and want zero-copy? 2. Cancellation: when data prop changes mid-flight, terminate worker and start new (current POC does this on unmount only). 3. Worker bundling: Vite/Webpack handle `new Worker(new URL(...))` in apps; the lib needs to ship a worker entry that survives bundling. 4. Multi-chart pages: one worker per chart vs shared pool.
Deploy previewhttps://deploy-preview-22366--material-ui-x.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
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.
Summary
POC for the Charts Performance — Data processing objective. Architecture spike for the async-pipeline approach (Option B in the findings doc).
Three pieces:
scatterWorker.ts— receives a Float64 (x, y) buffer + viewport metrics, computes the linear scale, and returns SVG path strings.AsyncScatter.tsx— experimental React component that renders a skeleton until the worker returns, then swaps in<path>elements.AsyncScatter.bench.tsx— pits the spike againstScatterChartat 100k and 1M.Bench (chromium, 800x400)
ScatterChartpaintCaveat
The component bypasses the lib's
ChartProviderpipeline; the 10× full-paint speedup conflates worker offload AND no-pipeline. Production integration re-adds the pipeline tax. First-paint win (skeleton) survives regardless.This POC validated the architecture; the proposed implementation is on
feat/async-chart-pipeline(#22370). Seecharts-perf-data-processing.md.Not for merge — POC reference, superseded by the async-pipeline plugin PR.