Skip to content

perf(rendering): reduce late-seek stalls in dense auto-zoom timelines - #3232

Merged
richiemcilroy merged 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:perf/narrow-zoom-timeline-time-mappings
Oct 25, 2026
Merged

richiemcilroy merged 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:perf/narrow-zoom-timeline-time-mappings

Conversation

@vedanth-jadhav

@vedanth-jadhav vedanth-jadhav commented Oct 25, 2026 •

Copy link
Copy Markdown

First seeks near the end of a densely edited project can spend hundreds of milliseconds preparing automatic zooms. Each 60 Hz simulation step scans the entire timeline-to-recording map, including intervals that cannot contain the requested time.

Validate once that mapping starts and ends are finite and nondecreasing. During simulation, use two binary bounds to pass only the potentially active overlapping intervals to the existing mapper. Keep the full scan for irregular/nonfinite maps, gaps, outside times and entry boundaries, preserving the mapper's first-entry shortcut and signed-zero arithmetic. The same clip preference and spring calculations run on the selected range. The map remains owned by the existing immutable zoom timeline; there is no new public API or cache lifecycle.

Native preview measurements

This measures the real EditorInstance preview path from sending a seek request to receiving its rendered-frame callback, including decoding, zoom preparation, uniforms, rendering and readback. It excludes editor construction and the initial frame at time 0. Every returned-frame fingerprint matches across both revisions and profiles.

Linux x86_64, AMD EPYC 9V74, two-CPU quota, affinity CPUs 0,1, Rust 1.88.0. Forced software Vulkan with Mesa 25.0.7 Lavapipe and two rasterizer threads. Five alternating independent processes per version/profile/workload; one first late seek per fresh editor; table shows process medians. UI window presentation and physical GPU performance were not measured.

Baseline 94a800cbac807f35a8bd3a862dd5d24853d8152c. The final branch is rebased onto current main. Subsequent caption projection, transcription and audio-cache changes are outside the fixture's exercised paths (no captions/audio); upstream zoom mapping code and compiler profiles are unchanged. Root release is opt-level=s/thin LTO/one codegen unit. The level-3 control overrides only cap-rendering; other packages retain the root profile.

Profile Project Before After Reduction
s 60min / 1000 cuts 400.7ms 148.3ms 63.0%
s 10min / 100 cuts 21.8ms 19.7ms 9.9%
o3 60min / 1000 cuts 427.1ms 147.7ms 65.4%
o3 10min / 100 cuts 21.1ms 19.5ms 7.5%

The dense fixture improves 2.7–2.9×, saving about 250–280ms on the first jump to 95% of the timeline. The shorter fixture saves only 1.6–2.2ms; it is a control rather than a noticeable user-facing claim. Editor-construction medians are 3.4–13.1% slower (4–17ms); those raw timings are retained, and no startup speedup is claimed. The meaningful result is removing the late-seek hitch in dense timelines.

Fixtures are synthetic: four recording sources sharing a generated 900-second 320×180 H.264 1fps intraframe clip, 100/1,000 timeline cuts, and 30 automatic zoom intervals covering 85% of the timeline. Cursor motion is deterministic at60 Hz; camera/cursor drawing are disabled and there are no audio tracks. The benchmark warms frame 0, then immediately requests the frame at95% at 30fps and 640×360. It compares complete visible-frame pixel fingerprints. The scope is the first seek/rebuild, since later seeks can reuse precomputed zoom samples.

This is distinct from #3225's cursor-spring reuse in preview/thumbnail: it changes zoom time-map lookup in zoom_spring.rs, not cursor interpolation/caching.

Correctness and checks

  • Differential mapping tests compare the unchanged full-scan mapper against narrowed ranges at endpoints and adjacent float values, overlaps, nested/reordered mappings, duplicate starts, gaps, holds, source preferences, signed zero and NaN/infinite values.
  • Complete zoom simulations compare every stored sample bit with indexing disabled as the reference, across incoming/outgoing source clips, transitions, holds and crop styles.
  • 36 zoom tests pass in debug and both release profiles; one existing benchmark is ignored.
  • cargo fmt --all --check, rendering all-target check, strict rendering-library Clippy and strict editor all-target Clippy with --no-deps pass.
  • Rendering strict all-target Clippy is blocked by two existing unused test helpers (layers/blur.rs:143, layers/camera3d.rs:164), also warned on the baseline. No suppression or unrelated cleanup is included.

Reproduction

Build this PR's example on both revisions, keeping only the example on the baseline. Save each binary separately before rebuilding:

cargo build -p cap-editor --release --locked --example zoom-seek-preview-benchmark
cargo build -p cap-editor --release --locked --example zoom-seek-preview-benchmark \
  --config profile.release.package.cap-rendering.opt-level=3
mkdir -p /tmp/cap-zoom-seek
ffmpeg -f lavfi -i testsrc2=size=320x180:rate=1 -t 900 \
  -c:v libx264 -preset ultrafast -threads 2 -g 1 -pix_fmt yuv420p \
  /tmp/cap-zoom-seek/display.mp4
taskset -c 0,1 /path/to/saved/zoom-seek-preview-benchmark /tmp/cap-zoom-seek

Native dependencies follow the contributor guide. For this headless result, point VK_DRIVER_FILES at a Lavapipe ICD, set CAP_RENDER_FORCE_SOFTWARE_ADAPTER=1 and LP_NUM_THREADS=2, and provide a writable XDG_RUNTIME_DIR. On a machine with a native GPU, the example can use the default adapter. Set CAP_ZOOM_DURATION=600 and CAP_ZOOM_CLIPS=100 for the shorter control. Alternate five saved baseline/head processes, compare fingerprint, and take medians of seek_seconds. startup_seconds is recorded separately.

Risk is confined to narrowing the mapper's search domain. Both endpoint orderings are validated once, the original arithmetic and source precedence are reused, and cases that cannot safely narrow retain the original full input. No frame sampling rate, spring behavior, decoder, project format or GPU shader changes.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

This PR reduces repeated timeline scans while preparing automatic zooms for late seeks.

  • Automatic zooms check fewer timeline entries during late seeks.
  • The editor example measures the first late-seek preview frame.

No actionable issues found. Tests and benchmark timings were not independently rerun.

Reviews (1) · Last reviewed commit: "perf(rendering): narrow time mappings fo..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

@richiemcilroy
richiemcilroy merged commit 21f5eaf into CapSoftware:main Oct 25, 2026
46 of 48 checks passed
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.

2 participants