Skip to content

Commit 25b42f5

Browse files
improve: retune scrub supersession span default
Co-authored-by: Richie McIlroy <richiemcilroy@users.noreply.github.com>
1 parent 57d54bf commit 25b42f5

3 files changed

Lines changed: 73 additions & 2 deletions

File tree

‎crates/editor/PLAYBACK-BENCHMARKS.md‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ cargo run -p cap-editor --example scrub-benchmark -- --video /path/to/video.mp4
9595
# Runtime tuning for FFmpeg scrub supersession heuristic
9696
CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_PIXELS=3686400 \
9797
CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_REQUESTS=8 \
98-
CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_SPAN_FRAMES=25 \
98+
CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_SPAN_FRAMES=20 \
9999
cargo run -p cap-editor --example scrub-benchmark -- --video /path/to/video.mp4
100100

101101
# Export per-run and aggregate scrub metrics to CSV
@@ -178,6 +178,39 @@ cargo run -p cap-recording --example playback-test-runner -- full
178178
- `cargo run -p cap-editor --example playback-startup-report -- --log crates/editor/PLAYBACK-BENCHMARKS.md --run-id sample-run`
179179
- Completed successfully with filtered metric output path active.
180180

181+
### Benchmark Run: 2026-02-14 00:00:00 UTC (supersession span retune to 20)
182+
183+
**Environment:** Linux runner with synthetic 4k60 and 1080p60 MP4 assets
184+
**Commands:** `scrub-benchmark --runs 3`, `playback-benchmark --seek-iterations 10`, `decode-benchmark --seek-iterations 10`
185+
**Change under test:** default `CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_SPAN_FRAMES` fallback changed from `25` to `20`
186+
187+
#### 4k scrub span sweep before promoting new default
188+
- Command family:
189+
- `CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_SPAN_FRAMES={15,20,25,30} scrub-benchmark --runs 3`
190+
- Median last-request latency by span:
191+
- **15**: avg **836.94ms**, p95 **1740.74ms**
192+
- **20**: avg **814.93ms**, p95 **1743.49ms**
193+
- **25**: avg **819.11ms**, p95 **1762.74ms**
194+
- **30**: avg **923.18ms**, p95 **1947.86ms**
195+
- Decision: promote span **20** as new default based on best median average and lower tail than span 25/30.
196+
197+
#### Scrub Benchmark — default after retune (span=20)
198+
- 4k60 (`/tmp/cap-bench-4k60.mp4`, runs=3):
199+
- Median all-request: avg **832.56ms**, p95 **1732.40ms**, p99 **1732.40ms**, max **1732.41ms**
200+
- Median last-request: avg **836.61ms**, p95 **1732.40ms**, p99 **1732.40ms**, max **1732.40ms**
201+
- 1080p60 (`/tmp/cap-bench-1080p60.mp4`, runs=3):
202+
- Median all-request: avg **222.58ms**, p95 **446.05ms**, p99 **472.21ms**, max **472.21ms**
203+
- Median last-request: avg **326.36ms**, p95 **472.21ms**, p99 **472.21ms**, max **472.21ms**
204+
205+
#### Regression checks after default retune
206+
- Playback throughput:
207+
- 1080p60: **60.24 fps**, missed deadlines **0**, decode p95 **2.24ms**
208+
- 4k60: **60.18 fps**, missed deadlines **2**, decode p95 **9.67ms**
209+
- Decode benchmark:
210+
- 1080p random access avg **111.79ms**, p95 **337.65ms**
211+
- 4k random access avg **509.26ms**, p95 **1451.87ms**
212+
- Duplicate burst handling remained stable (0 failures for burst sizes 4/8/16).
213+
181214
### Benchmark Run: 2026-02-14 00:00:00 UTC
182215

183216
**Environment:** Linux runner with synthetic 1080p60 and 4k60 MP4 assets

‎crates/editor/PLAYBACK-FINDINGS.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,44 @@ The CPU RGBA→NV12 conversion was taking 15-25ms per frame for 3024x1964 resolu
831831

832832
---
833833

834+
### Session 2026-02-14 (Supersession span threshold retune to 20)
835+
836+
**Goal**: Re-evaluate supersession span threshold with CSV-backed multi-run sweeps and improve 4k scrub medians
837+
838+
**What was done**:
839+
1. Ran a 4-way sweep over `CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_SPAN_FRAMES={15,20,25,30}` with `scrub-benchmark --runs 3`.
840+
2. Compared median last-request latency and p95 tails from CSV outputs.
841+
3. Updated FFmpeg supersession default span fallback from `25` to `20`.
842+
4. Re-ran scrub, playback, and decode regression benchmarks after the default change.
843+
844+
**Changes Made**:
845+
- `crates/rendering/src/decoder/ffmpeg.rs`
846+
- changed default `min_span_frames` fallback from `25` to `20`
847+
- `crates/editor/PLAYBACK-BENCHMARKS.md`
848+
- updated command examples to show span `20`
849+
- added benchmark entry for the threshold sweep and post-change regression runs
850+
851+
**Results**:
852+
- 4k sweep medians (last-request avg / p95):
853+
- span 15: **836.94ms / 1740.74ms**
854+
- span 20: **814.93ms / 1743.49ms**
855+
- span 25: **819.11ms / 1762.74ms**
856+
- span 30: **923.18ms / 1947.86ms**
857+
- Post-change default (span 20) validation:
858+
- 4k scrub median last-request avg **836.61ms**, p95 **1732.40ms**
859+
- playback throughput remains 60fps-class:
860+
- 1080p: **60.24 fps**
861+
- 4k: **60.18 fps**
862+
- decode metrics remain in expected variance envelope:
863+
- 1080p random avg **111.79ms**
864+
- 4k random avg **509.26ms**
865+
866+
**Decision**: keep defaults at `min_requests=8`, `min_span_frames=20`.
867+
868+
**Stopping point**: supersession defaults now favor a slightly more aggressive span threshold while preserving 60fps throughput and stable decode behavior.
869+
870+
---
871+
834872
### Session 2026-02-14 (Rejected superseded-burst cache-window reduction)
835873

836874
**Goal**: Reduce superseded scrub decode work by shrinking decode cache window for superseded requests

‎crates/rendering/src/decoder/ffmpeg.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn scrub_supersession_config() -> ScrubSupersessionConfig {
102102
.unwrap_or(8);
103103
let min_span_frames = parse_u32_env("CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_SPAN_FRAMES")
104104
.filter(|value| *value > 0)
105-
.unwrap_or(25);
105+
.unwrap_or(20);
106106
let min_pixels = parse_u64_env("CAP_FFMPEG_SCRUB_SUPERSEDE_MIN_PIXELS")
107107
.filter(|value| *value > 0)
108108
.unwrap_or(3_686_400);

0 commit comments

Comments
 (0)