diff --git a/crates/ui-egui/examples/perf_scenarios.rs b/crates/ui-egui/examples/perf_scenarios.rs index 2e4d79a56c..4ea1c1e87b 100644 --- a/crates/ui-egui/examples/perf_scenarios.rs +++ b/crates/ui-egui/examples/perf_scenarios.rs @@ -256,6 +256,9 @@ struct Sizes { a4: (u32, u32), /// A new 10 × 5 m document at 200 ppi (3.1 GP, #4017). huge_new: (u32, u32), + /// A huge document with one painted layer, refreshed zoomed out (#1015, #9330). The row name + /// leaves out the size because `--quick` uses a smaller one. + huge_doc: (u32, u32), } const FULL: Sizes = Sizes { @@ -269,6 +272,7 @@ const FULL: Sizes = Sizes { big_photo: (6000, 4000), a4: (2480, 3508), huge_new: (78_740, 39_370), + huge_doc: (30_000, 30_000), }; const QUICK: Sizes = Sizes { @@ -282,6 +286,7 @@ const QUICK: Sizes = Sizes { big_photo: (1600, 1066), a4: (1240, 1754), huge_new: (20_000, 10_000), + huge_doc: (8_000, 8_000), }; /// The layered document of #209: a background, six pixel layers with a drop shadow and a stroke, @@ -339,6 +344,11 @@ fn many_layers_doc(w: u32, h: u32, n: usize) -> Res<(Session, u64)> { Ok((s, mid)) } +/// The first top-level layer of the active document, other than `except`, that `want` accepts. +fn find_layer(s: &Session, except: u64, want: impl Fn(&photocraft_doc::Layer) -> bool) -> Option { + s.active()?.doc.layers.iter().find(|l| l.id.0 != except && want(l)).map(|l| l.id.0) +} + fn main() { let args: Vec = std::env::args().collect(); let quick = args.iter().any(|a| a == "--quick"); @@ -365,13 +375,14 @@ fn main() { // A panic in one group (a crash the scenario found) is reported against the row that was // running, and the other groups still run. type Group = fn(&mut Bench, &Sizes); - let groups: [(&str, Group); 6] = [ + let groups: [(&str, Group); 7] = [ ("layered", layered_scenarios), ("many layers", many_layer_scenarios), ("full-canvas layers", full_canvas_layer_scenarios), ("bit depths", depth_scenarios), ("long operations", job_scenarios), ("algorithms", algorithm_scenarios), + ("huge document", huge_document_scenarios), ]; let use_gpu = b.gpu.is_some(); if let Some(wanted) = arg(&args, "--group") @@ -477,6 +488,37 @@ fn layered_scenarios(b: &mut Bench, sz: &Sizes) { Ok(ms(t) + b.refresh(s, false)?) }); + // Advanced Blending on one layer sends the whole document to the CPU compositor (#6689): + // opacity edits on another layer, then the knockout is cleared again. + let other = find_layer(&s, target, |l| matches!(l.content, photocraft_doc::LayerContent::Raster(_)) && photocraft_compose::effects::has_effects(l)); + let adjustment = find_layer(&s, target, |l| matches!(l.content, photocraft_doc::LayerContent::Adjustment(_))); + match other { + Some(other) if exec(&mut s, "layer.layerStyle.blendingOptions", json!({"layer": other, "knockout": "shallow"})).is_ok() => { + let _ = b.refresh(&s, true); + b.time("set opacity on a layer with Advanced Blending + refresh", &mut s, reps, true, |b, s, i| { + let t = Instant::now(); + exec(s, "layer.setProps", json!({"layer": target, "opacity": if i % 2 == 0 { 0.6 } else { 0.9 }}))?; + Ok(ms(t) + b.refresh(s, false)?) + }); + let _ = exec(&mut s, "layer.layerStyle.blendingOptions", json!({"layer": other, "knockout": "none"})); + let _ = b.refresh(&s, true); + } + _ => b.errors.push(("set opacity on a layer with Advanced Blending + refresh".into(), "no second styled layer to knock out".into())), + } + // Hiding the Levels adjustment changes every pixel below it (#6535). + match adjustment { + Some(adj) => { + b.time("toggle adjustment layer visibility + refresh", &mut s, reps, true, |b, s, i| { + let t = Instant::now(); + exec(s, "layer.setProps", json!({"layer": adj, "visible": i % 2 == 1}))?; + Ok(ms(t) + b.refresh(s, false)?) + }); + let _ = exec(&mut s, "layer.setProps", json!({"layer": adj, "visible": true})); + let _ = exec(&mut s, "layer.select", json!({"layer": target})); + } + None => b.errors.push(("toggle adjustment layer visibility + refresh".into(), "no adjustment layer".into())), + } + // A layer filling the canvas, with a drop shadow (#761) and without (#128): dragged, it // overhangs the canvas edge. let full = (|| -> Res { @@ -554,7 +596,8 @@ fn layered_scenarios(b: &mut Bench, sz: &Sizes) { fn full_canvas_layer_scenarios(b: &mut Bench, sz: &Sizes) { let opacity = "opacity of a layer among many full-canvas layers + refresh"; let hide = "hide a layer among many full-canvas layers + refresh"; - if !b.wanted(opacity) && !b.wanted(hide) { + let adjust = "hide the top adjustment layer among many full-canvas layers, over the GPU budget + refresh"; + if !b.wanted(opacity) && !b.wanted(hide) && !b.wanted(adjust) { return; } b.current = Some(opacity.to_string()); @@ -582,17 +625,14 @@ fn full_canvas_layer_scenarios(b: &mut Bench, sz: &Sizes) { return; } }; + let mut app_budget = None; if let (Some((g, _)), Some(st)) = (&b.gpu, s.active()) { // As the app counts it (`canvas::gpu_budget`). let pixels = st.memory_bytes() as u64; let allowance = u64::from(photocraft_engine::prefs::Performance::default().memory_usage_mb) << 20; - g.set_memory_budget(photocraft_ui_egui::gpu_canvas::memory_budget( - allowance, - pixels, - photocraft_ui_egui::gpu_canvas::physical_memory(), - g.video_memory(), - 0, - )); + let budget = photocraft_ui_egui::gpu_canvas::memory_budget(allowance, pixels, photocraft_ui_egui::gpu_canvas::physical_memory(), g.video_memory(), 0); + g.set_memory_budget(budget); + app_budget = Some(budget); } let _ = b.refresh(&s, true); let reps = b.reps; @@ -606,6 +646,71 @@ fn full_canvas_layer_scenarios(b: &mut Bench, sz: &Sizes) { exec(s, "layer.setProps", json!({"layer": mid, "visible": i % 2 == 1}))?; Ok(ms(t) + b.refresh(s, false)?) }); + // #6533: an adjustment among them, added after the rows above so their document is unchanged. + // It lands on top (above the active `full n-1`), #6533's "hide the top adjustment layer" case. + let _ = exec(&mut s, "layer.setProps", json!({"layer": mid, "visible": true})); + b.current = Some(adjust.to_string()); + let adj = exec(&mut s, "layer.newAdjustmentLayer.levels", json!({"inBlack": 8, "inWhite": 245, "gamma": 1.05})).and_then(|_| active_layer(&s)); + match adj { + Ok(adj) => { + // As #6533's repro (`performance.gpuMemoryMb = 512`): the ~3.6 GB working set no longer + // fits, so a full refresh takes the from-scratch CPU path on every machine. + if let Some((g, _)) = &b.gpu { + g.set_memory_budget(photocraft_ui_egui::gpu_canvas::MIN_GPU_BUDGET); + } + let _ = b.refresh(&s, true); + // Each run is a from-scratch CPU composite of 150 full-canvas layers. Every timed run + // is a hide: the layer is shown again, untimed, before each one. + b.time(adjust, &mut s, reps.min(5), true, |b, s, _| { + exec(s, "layer.setProps", json!({"layer": adj, "visible": true}))?; + b.refresh(s, false)?; + let t = Instant::now(); + exec(s, "layer.setProps", json!({"layer": adj, "visible": false}))?; + Ok(ms(t) + b.refresh(s, false)?) + }); + } + Err(e) => b.errors.push((adjust.to_string(), e)), + } + // `b.gpu` is shared with the later groups: give them back the budget they see on main. + if let (Some((g, _)), Some(budget)) = (&b.gpu, app_budget) { + g.set_memory_budget(budget); + } +} + +/// #1015, #9330: a huge document with one painted layer, zoomed out: times only the reduced CPU +/// composite `canvas::ensure_texture` draws when the document is too large for GPU textures. +fn huge_document_scenarios(b: &mut Bench, sz: &Sizes) { + let name = "zoomed-out reduced composite of the huge document with one painted layer"; + if !b.wanted(name) { + return; + } + b.current = Some(name.to_string()); + let (w, h) = sz.huge_doc; + let mut s = Session::new(); + let built = (|| -> Res<()> { + exec(&mut s, "file.new", json!({"width": w, "height": h, "background": "white"}))?; + exec(&mut s, "layer.new.layer", json!({"name": "paint"}))?; + exec(&mut s, "select.rect", json!({"x": w / 4, "y": h / 4, "width": w / 2, "height": h / 2}))?; + exec(&mut s, "edit.fill", json!({"color": "#c03020"}))?; + exec(&mut s, "select.deselect", json!({}))?; + Ok(()) + })(); + if let Err(e) = built { + b.errors.push((name.into(), e)); + return; + } + // One run: each is a from-scratch reduced composite of the whole document. + b.time(name, &mut s, 1, false, |_, s, _| { + let doc = &s.active().ok_or("no document")?.doc; + let factor = w.max(h).div_ceil(photocraft_ui_egui::canvas::MAX_TEXTURE).max(1); + let t = Instant::now(); + let reduced = photocraft_compose::render_reduced(doc, w / factor, h / factor); + let v = ms(t); + if reduced.px.is_empty() { + return Err("the reduced canvas is empty".into()); + } + Ok(v) + }); } /// #209: arrow-key nudge in the 150-layer document; #1771: a new layer there. diff --git a/docs/scorecard.md b/docs/scorecard.md index 70b08b831b..95e84060ce 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -6,7 +6,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | Area | Done | Partial | Missing | Key numbers | |---|---:|---:|---:|---| -| [Performance](#performance) | 3 | 22 | 31 | 65 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 27 not run, 4 not measurable yet (baseline 2026-10-05) | +| [Performance](#performance) | 3 | 22 | 42 | 76 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 38 not run, 4 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 11 | 14 | 2 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 | | [Tools](#tools) | 36 | 9 | 0 | | | [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 12 of 181 (target 0) | @@ -85,6 +85,17 @@ Baseline: 2026-10-05, commit `f5d2bcb54a`, Apple M4 Pro (48 GB), GPU Apple M4 Pr | P66 | Relight on 24 MP | ≤ 1000 ms p95 | – | – | – | – | – | not run | [#211](https://github.com/storytold/photocraft/issues/211) | | P67 | Reduce Noise on 24 MP | ≤ 1000 ms p95 | – | – | – | – | – | not run | [#211](https://github.com/storytold/photocraft/issues/211) | | P68 | Photomerge multi-band blend, synthetic | track timing and peak RSS; no calibrated performance budget | – | – | – | – | – | not run | [#7758](https://github.com/storytold/photocraft/issues/7758) | +| P69 | Move a layer with layer styles, CPU compositor | track only | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P70 | Change layer opacity, CPU compositor | ≤ 40 ms p95 | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P71 | Change layer fill, CPU compositor | ≤ 40 ms p95 | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P72 | Change blend mode, CPU compositor | ≤ 40 ms p95 | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P73 | Toggle visibility, CPU compositor | ≤ 20 ms p95 | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P74 | Undo a move, CPU compositor | track only | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P75 | Redo an opacity change, CPU compositor | track only | – | – | – | – | – | not run | [#9330](https://github.com/storytold/photocraft/issues/9330) | +| P76 | Change layer opacity with Advanced Blending on another layer | ≤ 40 ms p95 | – | – | – | – | – | not run | [#6689](https://github.com/storytold/photocraft/issues/6689) | +| P77 | Toggle an adjustment layer's visibility | ≤ 10 ms p95 | – | – | – | – | – | not run | [#6535](https://github.com/storytold/photocraft/issues/6535) | +| P78 | Hide the top adjustment layer among 150 full-canvas layers, 6 MP, GPU budget forced to 512 MB (CPU fallback) | ≤ 30 ms p95 | – | – | – | – | – | not run | [#6533](https://github.com/storytold/photocraft/issues/6533) | +| P79 | Zoomed-out reduced composite of a 30000x30000 document with one painted layer (#9330 target: 60000x60000) | track only | – | – | – | – | – | not run | [#1015](https://github.com/storytold/photocraft/issues/1015) | **Not measurable yet** (the code can't do it yet; no number is recorded): diff --git a/perf/budgets.toml b/perf/budgets.toml index 7a16f37e2f..d2ba30473f 100644 --- a/perf/budgets.toml +++ b/perf/budgets.toml @@ -23,6 +23,14 @@ package = "photocraft-ui-egui" quick_args = ["--quick"] note = "the #209/#210/#211 rows: layered 20 MP, 150 layers, 16/32-bit, open, retouch, selection" +[[bench]] +name = "perf_scenarios_cpu" +package = "photocraft-ui-egui" +example = "perf_scenarios" +args = ["--cpu", "--group", "layered"] +quick_args = ["--quick", "--cpu", "--group", "layered"] +note = "the layered #209 rows on the forced CPU compositor (#9330); run with perf_scenarios so the machine class keeps the GPU" + [[bench]] name = "interactive_bench" package = "photocraft-ui-egui" @@ -631,3 +639,100 @@ issue = 7758 bench = "bench_multiband" row = "Photomerge multiband blend" target = "track timing and peak RSS; no calibrated performance budget" + +# ---- cliff rows (#7494): off-happy-path paths, reported only --------------------------------- + +[[scenario]] +id = "P69" +title = "Move a layer with layer styles, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "move styled layer 10 px + refresh" +enforce = false # tracked only + +[[scenario]] +id = "P70" +title = "Change layer opacity, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "set layer opacity + refresh" +budget_ms = 40 +enforce = false # #9330 done-when: within 2x the GPU budget + +[[scenario]] +id = "P71" +title = "Change layer fill, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "set layer fill + refresh" +budget_ms = 40 +enforce = false # #9330 done-when: within 2x the GPU budget + +[[scenario]] +id = "P72" +title = "Change blend mode, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "set blend mode + refresh" +budget_ms = 40 +enforce = false # #9330 done-when: within 2x the GPU budget + +[[scenario]] +id = "P73" +title = "Toggle visibility, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "toggle visibility + refresh" +budget_ms = 20 +enforce = false # #9330 done-when: within 2x the GPU budget + +[[scenario]] +id = "P74" +title = "Undo a move, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "undo move + refresh" +enforce = false # tracked only + +[[scenario]] +id = "P75" +title = "Redo an opacity change, CPU compositor" +issue = 9330 +bench = "perf_scenarios_cpu" +row = "redo opacity change + refresh" +enforce = false # tracked only + +[[scenario]] +id = "P76" +title = "Change layer opacity with Advanced Blending on another layer" +issue = 6689 +bench = "perf_scenarios" +row = "set opacity on a layer with Advanced Blending + refresh" +budget_ms = 40 +enforce = false # new; 2x P2 + +[[scenario]] +id = "P77" +title = "Toggle an adjustment layer's visibility" +issue = 6535 +bench = "perf_scenarios" +row = "toggle adjustment layer visibility + refresh" +budget_ms = 10 +enforce = false # new; as P5 + +[[scenario]] +id = "P78" +title = "Hide the top adjustment layer among 150 full-canvas layers, 6 MP, GPU budget forced to 512 MB (CPU fallback)" +issue = 6533 +bench = "perf_scenarios" +row = "hide the top adjustment layer among many full-canvas layers, over the GPU budget + refresh" +budget_ms = 30 +enforce = false # new; as P61 + +[[scenario]] +id = "P79" +title = "Zoomed-out reduced composite of a 30000x30000 document with one painted layer (#9330 target: 60000x60000)" +issue = 1015 +bench = "perf_scenarios" +row = "zoomed-out reduced composite of the huge document with one painted layer" +enforce = false # tracked only