8000 perf: cut 60 Hz rework from timeline/triage/scope, fix pill auto-persist, dedup helpers by johannboehme · Pull Request #63 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

perf: cut 60 Hz rework from timeline/triage/scope, fix pill auto-persist, dedup helpers - #63

Merged
johannboehme merged 3 commits into
mainfrom
claude/beautiful-kirch-d958ac
Jul 5, 2026
Merged

johannboehme merged 3 commits into
mainfrom
claude/beautiful-kirch-d958ac

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

Optimization pass across the hot render paths plus one real data-loss fix. No functional changes intended — UI and behavior are identical, the same work just stops being redone every playback frame.

Bug fix

  • Pill edits were never auto-saved: useAutoPersist's dirty-check didn't watch state.pills, although the persist patch writes them. A pill move/trim alone never scheduled a save, so a refresh lost it. The check is extracted as a tested persistRelevantChanged() helper (red-checked) and now includes pills.
  • snapTime with a non-finite BPM returns the input unchanged instead of Infinity.

Performance (all: stop per-frame recomputation of frame-invariant work)

  • Editor Timeline canvas (redraws every playback frame by design): pill filter/sort/id/dirty arrays per cam, segment geometry, trim + audio-start projections are now memoized on their real inputs; the waveform's arr→master projection reuses column boundaries (halves the binary searches, ~5k/frame on retina) plus a last-hit segment cache; scratch buffers replace per-run Float32Array allocations in the shared waveform engine.
  • Triage waveform: timeToX/xToTime were plain functions in effect deps — with the component re-rendering on every playhead tick, the full hi-res waveform (envelope scan + silence tint included) redrew 60×/s during playback and window drag-listeners re-installed per tick. Now useCallback on the view inputs.
  • SidechainScope: both SVG envelope paths (columns × sub-samples lookups + arr→master projections) and the beat grid rebuilt per timelineT tick; now memoized — only the playhead line moves per tick.
  • ProgramStrip: memo()ed with stable callbacks from the Timeline, so the strip's DOM (program segments, splice tabs, FX tape) no longer reconciles every playback frame.

Cleanup

  • New lib/clamp.ts (clamp/clamp01/clampSeek) replaces 13 identical local copies; useAudioMaster keeps its own clampSeek variant (different NaN semantics, hot playback path).
  • New lib/time-format.ts replaces 5 byte-identical formatTime copies (MonoReadout's MM:SS.ff variant intentionally stays local).
  • Removed unused isPreviewEmpty from quantize.ts.

Verification

  • 1224 unit tests green (15 new: clamp, time-format, degenerate-BPM snap, persist dirty-check incl. red-check), tsc clean.
  • Browser suite green; the GPU stress bench flakes only under full-suite parallel load (p95 4.1 ms in isolation vs 16 ms budget — pre-existing contention flake, also on baseline).
  • Compositor stress bench and WebGPU readback bench pass with wide margin after the changes.

🤖 Generated with Claude Code

johannboehme and others added 3 commits July 5, 2026 10:35
…s draw

- Pills: filter/sort/id/dirty arrays per cam computed once per pills change
  instead of per clip per frame
- Segment geometry (arrStarts/segBounds), trim projections and audio-start
  marker positions memoized on their actual inputs
- Waveform arr→master projection: reuse column boundaries (one mapXToTime
  call per boundary instead of two) and cache the last-hit segment for
  strictly-interior queries
- drawRun: shared scratch buffers instead of two Float32Array allocations
  per run
- camStatusByCamId: drop the O(n²) ranges.find

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…op dead code

- New src/lib/clamp.ts (clamp / clamp01 / clampSeek) replaces 13 identical
  local copies across editor, triage and arrange. useAudioMaster keeps its
  own clampSeek variant (different NaN semantics, hot playback path).
- New src/lib/time-format.ts replaces 5 byte-identical M:SS formatTime
  copies; MonoReadout's MM:SS.ff variant intentionally stays local.
- snapTime: non-finite bpm now falls back to 'no grid' instead of
  returning Infinity.
- Remove unused isPreviewEmpty from quantize.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rework in Triage waveform, SidechainScope, ProgramStrip

- useAutoPersist: the dirty-check didn't watch state.pills although the
  patch persists them — a pill move/trim alone was never saved and a
  refresh lost it. Extracted the check as persistRelevantChanged()
  (tested, incl. red-check) and added pills.
- TriageTimeline: timeToX/xToTime were plain functions (fresh identity
  per render) sitting in effect deps; the component re-renders on every
  playhead tick, so the full hi-res waveform redrew 60×/s during
  playback and the window drag-listeners re-installed per tick. Now
  useCallback on [viewStartS, pxPerSec].
- SidechainScope: both SVG area paths (columns × sub-samples envelope
  lookups + arr→master projections) and the beat grid rebuilt on every
  timelineT tick; now memoized on the window/curve inputs — only the
  playhead line moves per tick.
- ProgramStrip: memo()ed, with stable callbacks + memoized paint-preview
  from the Timeline, so the strip's DOM (segments, splice tabs, FX tape)
  no longer reconciles every playback frame. LaneHeader's canReset now
  reads the precomputed per-cam dirty flags.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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

0