Repository navigation
perf(gpui): avoid whole-timeline copies during clip trim previews - #3439
himanshu748 wants to merge 2 commits into
Conversation
|
@himanshu748 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| && self | ||
| .segments_for(model, row) |
There was a problem hiding this comment.
row_selected accepts model: &TimelineModel, but the new call to self.segments_for requires model: &'a TimelineModel. The input does not promise that lifetime, so this fails to compile with an explicit-lifetime-required error. Change the parameter to model: &'a TimelineModel, or let segments_for borrow both inputs for a shorter shared lifetime.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/editor_timeline.rs
Line: 1854-1855
Comment:
**Native app cannot build**
`row_selected` accepts `model: &TimelineModel`, but the new call to `self.segments_for` requires `model: &'a TimelineModel`. The input does not promise that lifetime, so this fails to compile with an explicit-lifetime-required error. Change the parameter to `model: &'a TimelineModel`, or let `segments_for` borrow both inputs for a shorter shared lifetime.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Dragging a clip edge and playing its release animation currently clone the entire timeline on each redraw, including unrelated captions, keyboard events, overlays and waveform-reference vectors. Preparing the preview therefore gets more expensive as those other tracks grow.
Prepare only the clip vector and trim gap, then borrow the unchanged timeline through
SegmentUi. Clip rows, selection rendering and speed controls use the same preview slice. The existing trim/source-range and easing calculations are unchanged. There is no cache to invalidate, and idle/draft frames do not gain a clock read.Measurements
These are isolated preview preparation plus result destruction, not GPUI painting, frame rate, decoding or end-to-end input latency. Synthetic prebuilt models use the same fixture helpers as the committed ignored benchmark. Fixture construction is outside the timed region.
Linux x86-64, AMD EPYC 7763, rustc 1.99.1; optimized with
opt-level=3, one codegen unit, no LTO. Each of three processes runs 10 warmup pairs and 31 alternating paired samples; batches contain 128 preparations, or 16 for the 10,000-caption cases. Values below are medians of the three process medians, for owned long labels during an active end trim.For each caption count, keyboard events = captions / 4; each of text, image, style, mask and audio overlays = captions / 100. Nonempty caption cases also contain one zoom, scene and 3D segment. These are explicit scaling fixtures, not estimates of typical project sizes.
The full matrix also covers static and short labels, animation at 90 ms, and idle. The 24-clip/1,000-caption owned-label animation measured 22.015 → 0.553 µs. Small cases have limited benefit: the 200-clip/no-caption short-label trim measured 3.225 → 3.233 µs (about 0.2% slower, with per-process before/after ratios 0.997–1.068). Idle is a few-nanosecond noise control; no idle speedup is claimed.
A separate allocation-counting binary measured the 24-clip/1,000-caption trim at 16 → 2 allocations and 138,688 → 2,880 requested bytes. Its animation uses 15 → 1 allocations. Allocation counters are absent from the timing binary. These are requested bytes, not resident or retained memory; waveform samples were already shared and are not deep-copied by either version.
The isolated harness extracts the baseline from
8dd141d17ea2dd592f326fdb3358f798e3c7f8baand the changed production methods/types. It uses current project types and GPUI's actualSharedStringrepresentation with SmolStr 0.3.6. Unused editor fields and string traits are omitted; the never-dereferenced waveform-path referent is a stand-in while itsArcclone/drop operations remain. Both paths receive the same deterministic time. This is not a full native build.Correctness and reproduction
Repeat the benchmark in three processes to compare medians. The native release profile uses thin LTO, unlike the isolated measurements above, so its timings may differ.
Formatting and diff checks pass. Local native application checking was interrupted after confirming the missing ALSA prerequisite; a focused
alsa-syscheck fails becausepkg-configcannot findalsa.pc. The four native GPUI tests and native benchmark have not been run locally. Native CI, manual GUI interaction, pixel comparisons and end-to-end latency measurements remain outstanding at draft creation.Fix the lifetime mismatch in
row_selectedbefore merging.Findings
Fix with agent prompt
Summary
Replaces whole-timeline copies with a clip-only preview during trimming and release animation.
Reviews (1) · Last reviewed commit: "test(gpui): render clip preview smoke te..." · Reviewed by Greptile