Skip to content

perf(studio): a long project's clips get their durations in one update per source - #6765

Closed
miguel-heygen wants to merge 1 commit into
mainfrom
perf/cliprobe-probe-batch
Closed

miguel-heygen wants to merge 1 commit into
mainfrom
perf/cliprobe-probe-batch

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

No measured playback gain; kept only if the per-source batching stands on its own.

What

Opening a long project in Studio now updates the timeline once per media source as its length is read, not once per clip.

Why

A project with hundreds of clips over a few dozen files made the timeline store publish a full copy of its element list for every clip as each file's header was read. Every publish woke the timeline's subscribers (row virtualization, scroll snapshots, cursor anchoring), which read layout each time. A CPU profile of a 600-clip project's first playback listed these costs (media probe completion, row virtualization layout effect, scroll snapshot, cursor anchor DOM queries) and about 13 ms of 49 s in the media fetch stream wrapper, so this is not a streaming problem.

Related work

None open on this path.

How

  • probeMissingSourceDurations now calls apply with a key -> seconds map; clips sharing a source resolve in the same microtask run, so one source is one call.
  • useTimelinePlayer patches every matching element in one setState, and returns the same state when nothing needs patching, so an already-measured clip publishes nothing (the old {} return still notified).

Test plan

fails without the fix: hands the durations of clips sharing a source over in one call in packages/studio/src/player/lib/mediaProbe.test.ts; with the single-flush guard removed it fails with expected "vi.fn()" to be called 1 times, but got 3 times.

What I measured

  • mediaProbe.test.ts and src/player/hooks: 216 tests green, three runs; oxfmt and oxlint clean on packages/studio/src/player.
  • Studio playback in headless Chrome on a shared Linux box, 600 clips over 30 sources, four busy loops, frame rate of the page over 10 s divided by an empty page's: before 0.825, 0.828, 0.813; after 0.822, 0.615, 0.732. No improvement (the box was shared, so the spread is noise); the batching does not change this scenario.

What I did NOT execute

  • A reproduction of the reported slowdown. My generated 600-clip, 30-source project did not fall to a low ratio even before this change, so this PR is not shown to fix it.

  • tsc for packages/studio (workspace unbuilt on the test box).

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments"

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 146 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (2)

  • seqplainkeys-none-center-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true
  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Superseded by #6773: the redraw per publish was the cost, not the number of publishes; this batching moved no measurement.

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