Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/editor/examples/editor-startup-benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ async fn main() {
.map(|seconds| (seconds * fps as f64).round() as u32)
})
.unwrap_or(0);
let scrub_requests = arg_value(&args, "--scrub-requests")
.and_then(|s| s.parse::<u32>().ok())
.unwrap_or(0);
let profile_stages = has_flag(&args, "--profile-stages");
let profile_stages_only = has_flag(&args, "--profile-stages-only");
let prewarm_fonts = has_flag(&args, "--prewarm-fonts");
Expand All @@ -175,6 +178,7 @@ async fn main() {
println!("Recording: {}", recording_path.display());
println!("Runs: {runs}");
println!("Preview frame: {preview_frame}");
println!("Scrub requests: {scrub_requests}");
println!("Profile stages: {profile_stages}");
println!("Profile stages only: {profile_stages_only}");
if prewarm_fonts {
Expand All @@ -194,6 +198,7 @@ async fn main() {

let mut values_ms = Vec::with_capacity(runs);
let mut preview_values_ms = Vec::with_capacity(runs);
let mut scrub_values_ms = Vec::with_capacity(runs * scrub_requests as usize);

for run in 0..runs {
let before_config = ProjectConfiguration::load(&recording_path).unwrap_or_default();
Expand Down Expand Up @@ -227,6 +232,19 @@ async fn main() {
let preview_elapsed = preview_start.elapsed().as_secs_f64() * 1000.0;
preview_values_ms.push(preview_elapsed);

for request in 0..scrub_requests {
let frame = preview_frame + request.abs_diff(scrub_requests / 2) * (fps / 4);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Scrub benchmark can time out

The new loop can request frames past the recording’s end. For a 10-second recording, --preview-time 8 --scrub-requests 60 at the default 60 fps requests 15.5 seconds first. The renderer produces no callback for that frame, so the benchmark waits 10 seconds and panics instead of reporting results. Keep generated scrub frames within the timeline’s valid range.

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/editor/examples/editor-startup-benchmark.rs
Line: 236

Comment:
**Scrub benchmark can time out**

The new loop can request frames past the recording’s end. For a 10-second recording, `--preview-time 8 --scrub-requests 60` at the default 60 fps requests 15.5 seconds first. The renderer produces no callback for that frame, so the benchmark waits 10 seconds and panics instead of reporting results. Keep generated scrub frames within the timeline’s valid range.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid, the drag can run past the end of a short recording. I'm not fixing it here: #2476 merged the same zoom-cache change, so this PR is superseded and I expect to close it.

let scrub_start = Instant::now();
editor
.preview_tx
.send(Some((frame, fps, resolution_base)))
.expect("Failed to request scrub frame");
frame_rx
.recv_timeout(Duration::from_secs(10))
.expect("Scrub did not produce a frame within 10 seconds");
scrub_values_ms.push(scrub_start.elapsed().as_secs_f64() * 1000.0);
}

editor.dispose().await;
tokio::time::sleep(Duration::from_millis(100)).await;

Expand Down Expand Up @@ -266,6 +284,17 @@ async fn main() {
preview_values_ms.len()
);

if !scrub_values_ms.is_empty() {
let scrub_avg = scrub_values_ms.iter().sum::<f64>() / scrub_values_ms.len() as f64;
let scrub_max = scrub_values_ms.iter().copied().fold(0.0, f64::max);
println!(
"Scrub preview: avg={scrub_avg:.1}ms p50={:.1}ms p95={:.1}ms max={scrub_max:.1}ms samples={}",
percentile(&scrub_values_ms, 50.0),
percentile(&scrub_values_ms, 95.0),
scrub_values_ms.len()
);
}

if profile_stages {
run_stage_profile(recording_path, runs).await;
}
Expand Down
Loading