Repository navigation
perf(editor): cache waveform pyram 8000 id on open — 9.8s→10ms for longform - #62
Merged
Merged
Conversation
The editor rebuilt the waveform peak-pyramid from a full audio decode on every open (it called buildPeakPyramidAsync directly, ignoring the IDB cache the sync step and Triage already use). For a 16-min longform track that is ~9.8s of blank "Loading editor…" — on every single open. Measured on real jobs (963s longform), foreground tab: "Loading editor" clears: 9820ms → 10ms interactive: 9938ms → 138ms - load-master-audio.ts (TDD, 7 tests): cached-pyramid-first. The cached pyramid carries the true master duration, so loadJob gets its duration with no decode. A cache miss decodes+builds once and persists, so the next open is instant (self-healing for pre-cache jobs). - The full decode now only runs in the background, for the sidechain loudness envelope — off the "Loading editor" critical path. - Cam-URL resolution parallelized (was a serial per-cam OPFS loop). - Per-phase load timing behind ?perf=1. - editor-load.bench.browser.test.ts: real-Chromium pipeline benchmark that confirmed decode/pyramid/analysis compute is sub-second — the cost was the per-open rebuild, not the math. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Opening the editor sat on a blank "Loading editor…" screen far longer than the JS bundle or file IO could explain.
Root cause (measured on real jobs, not guessed)
The editor rebuilt the waveform peak-pyramid from a full audio decode on every open — it called
buildPeakPyramidAsyncdirectly and ignored the IDB pyramid cache that the sync step (jobs.ts:567) and Triage already populate/read. For a 16-minute long-form track that is ~9.8 s of blank screen, every single open.Measured via CDP against real project data (963 s long-form job, foreground tab):
"Loading editor"clearsA real-Chromium pipeline benchmark confirmed the per-sample compute (decode/pyramid/analysis/loudness) is sub-second even at 15 min — the cost was the per-open rebuild, not the math. The ~30 s I first observed externally was background-tab rAF throttling, not real load.
Changes
load-master-audio.ts(TDD, 7 tests) — cached-pyramid-first. The cached pyramid carries the true master-audio duration, soloadJobgets its duration without decoding a single sample. A cache miss decodes + builds once and persists it, so the next open is instant (self-healing for jobs synced before the pyramid cache existed).Editor.tsx— wire the cache; the full decode now runs only in the background for the sidechain loudness envelope, off the critical path; cam-URL resolution parallelized (was a serial per-cam OPFS loop); per-phase load timing behind?perf=1.editor-load.bench.browser.test.ts— real-Chromium benchmark of the load pipeline.Testing
vitest --project=unit: 1209 passed (incl. 7 newload-master-audiotests)tsc --noEmit: cleanFollow-up (not in this PR)
The background decode (~10 s CPU per open, non-blocking, only for the sidechain loudness envelope) could be eliminated by persisting the loudness envelope like the pyramid/analysis caches.
🤖 Generated with Claude Code