Repository navigation
perf(core): a film opens and seeks without pre-styling every hidden scene, cuts stay smooth - #6356
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 186 of thoseThe gate passes. Quarantined, measured but not gated (0) |
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head e9106cc1
The pass now runs only while playing, for hidden clips whose start is within LOOKAHEAD_SECONDS, with the same start resolver dueSoon uses. Clips that are shown, disconnected, or already past their start leave the set without a pass, so the set stays small. CI, Player perf and regression are green. Player Safari perf was still running at review time.
Scope
Read styleClipsDueVisibleOnce and its only call site (seekRootChildrenAndAdapters), the add site in the visibility pass (clipsNeverStyledVisible.add), dueSoon/LOOKAHEAD_SECONDS (declared after the closure but only read at call time, so no TDZ), and the updated init.test.ts case. By design, paused seeks, scrubs and render-mode seeks skip the pass. Perf tables taken as reported.
What
#6189 gives each clip the visibility pass hides its first visible style pass once, on the next seek, so a cut frame does not pay it. That pass also ran at open and after every mount, including far scenes a scrub only passes over. This change runs it only while playing, for clips whose start is within the 2 s lookahead: the scene about to be cut into gets it 1-2 s before its cut, and open, seeks and scrubs skip it.
packages/core/src/runtime/init.ts:styleClipsDueVisibleOnce(t)replacesstyleHiddenClipsVisibleOnce(); a hidden clip waits in the set until playing brings its start within the lookahead, and leaves it once styled, shown, or past its start.Measurements
Software-rendered machine (shared Linux box, 8 cores, SwiftShader, headless Chrome 152). 3 runs per cell, alternating columns. Columns: main before #6189 (26e3045), #6189's head (80e934a, measured with its runtime d4ff3fc), and this change. Load is the 1-minute load during each table's runs.
Play and scrub, 23-minute film. Open: play 6 s from the start right after the page is ready, then scrub ahead from 700 s at 2 s of film per frame for 5 s. After a seek: the same, after a seek to 4 s before the cut at 633.9 s. Warm: seek 2 s past that cut and settle, scrub ahead from 300 s, then play from 4 s before the cut.
Open and the first seek. A fresh browser opens the film, waits for ready and 3 s, then seeks once and waits for the seek to complete and two frames.
Cut frames. The main-thread task of the first frame whose film time passes each scene start, during play from about 0.5 s before it. Main against this change.
Unconfirmed: the 599 ms run at 40.04 s (load 7.7) is one run of three; a low-load re-run of that cut is pending. Several cells ran above load 6; they are re-run at lower load as the machine allows.
Tests
init.test.ts: a hidden clip, its far scene included, is styled visible once while playing toward its start, not while paused and not before its start is within the lookahead. It fails with each of these removed, one at a time: the pass itself, the playing check (styled while paused), the lookahead bound (styled 4 s early), the far-scene unlock.init.test.ts,init.swapScenes.test.ts,timedClipHide.test.ts,farScenes.test.ts; 432 passed), the new test 3 runs in a row, the core typecheck and the formatter. The same run on this branch's base is in progress.