mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
# Conflicts: # crates/algo/examples/bench_seam.rs # crates/algo/src/seam.rs # docs/gaps.md # docs/target-app-parity.md # perf/budgets.toml
This commit is contained in:
commit
8fe70c95d2
7 files changed
+916
-311
No files matched your search
@@ -0,0 +1,78 @@
|
||||
//! Timing of Content-Aware Scale's seam carving alone (no document plumbing), on a synthetic
|
||||
//! photo-like RGBA image: perf scenario P28's 24 MP width change (#211), the same image's height
|
||||
//! (the transposed pass) and two images short enough for the exact full-resolution seam search.
|
||||
//! Prints an FNV-style hash of each output's bits (over 32-bit words), so a speed-up can be checked
|
||||
//! to choose exactly the same seams.
|
||||
//! `cargo run --release -p photocraft-algo --example bench_seam_cas [reps] [case filter]`
|
||||
use std::time::Instant;
|
||||
|
||||
use photocraft_algo::seam::carve;
|
||||
|
||||
/// Smooth gradients, a few hard-edged shapes and fine noise: enough structure that seams are
|
||||
/// steered by content, as in a photo.
|
||||
fn photo(w: usize, h: usize) -> Vec<f32> {
|
||||
let mut seed = 0x9e37_79b9u32;
|
||||
let mut noise = move || {
|
||||
seed ^= seed << 13;
|
||||
seed ^= seed >> 17;
|
||||
seed ^= seed << 5;
|
||||
(seed % 1000) as f32 / 1000.0 - 0.5
|
||||
};
|
||||
let mut img = Vec::with_capacity(w * h * 4);
|
||||
for y in 0..h {
|
||||
for x in 0..w {
|
||||
let (u, v) = (x as f32 / w as f32, y as f32 / h as f32);
|
||||
let sky = 0.35 + 0.4 * v;
|
||||
let disc = ((u - 0.3).powi(2) + (v - 0.55).powi(2)) < 0.02;
|
||||
let bar = (0.62..0.66).contains(&u) && v > 0.3;
|
||||
let hill = v > 0.7 + 0.08 * (u * 11.0).sin();
|
||||
let (r, g, b) = if disc {
|
||||
(0.85, 0.3, 0.2)
|
||||
} else if bar {
|
||||
(0.1, 0.1, 0.12)
|
||||
} else if hill {
|
||||
(0.2, 0.45 + 0.1 * (u * 40.0).sin(), 0.15)
|
||||
} else {
|
||||
(sky * 0.6, sky * 0.8, sky)
|
||||
};
|
||||
let n = noise() * 0.02;
|
||||
img.extend_from_slice(&[r + n, g + n, b + n, 1.0]);
|
||||
}
|
||||
}
|
||||
img
|
||||
}
|
||||
|
||||
fn fnv(v: &[f32]) -> u64 {
|
||||
v.iter().fold(0xcbf2_9ce4_8422_2325u64, |h, f| (h ^ u64::from(f.to_bits())).wrapping_mul(0x0100_0000_01b3))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let reps = args.get(1).and_then(|s| s.parse::<usize>().ok()).unwrap_or(1).clamp(1, 20);
|
||||
let only = args.get(2).cloned();
|
||||
// (name, w, h, new w, new h)
|
||||
let cases = [
|
||||
("24 MP to 90 % width (P28, proxy rows)", 6000, 4000, 5400, 4000),
|
||||
("24 MP to 90 % height (transposed, proxy rows)", 6000, 4000, 6000, 3600),
|
||||
("5.4 MP to 90 % width (exact)", 3000, 1800, 2700, 1800),
|
||||
("1.5 MP to 70 % width (exact)", 1500, 1000, 1050, 1000),
|
||||
];
|
||||
for (name, w, h, nw, nh) in cases {
|
||||
if only.as_ref().is_some_and(|o| !name.contains(o.as_str())) {
|
||||
continue;
|
||||
}
|
||||
let img = photo(w, h);
|
||||
let mut times = Vec::with_capacity(reps);
|
||||
let mut hash = 0;
|
||||
for _ in 0..reps {
|
||||
let t = Instant::now();
|
||||
let out = carve(w, h, 4, &img, None, nw, nh);
|
||||
times.push(t.elapsed().as_secs_f64() * 1000.0);
|
||||
hash = fnv(&out);
|
||||
}
|
||||
times.sort_by(f64::total_cmp);
|
||||
let p50 = times[times.len() / 2];
|
||||
let max = times[times.len() - 1];
|
||||
println!("{name:<48} p50 {p50:>9.1} ms max {max:>9.1} ms output {hash:016x}");
|
||||
}
|
||||
}
|
||||
+627
-230
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,50 @@
|
||||
//! End-to-end timing of `edit.contentAwareScale` (perf scenario P28, #211) without the UI: a
|
||||
//! synthetic 24 MP RGB photo opened from JPEG like `perf_scenarios`' (gradients, soft blobs, fine
|
||||
//! noise and a high-contrast disc), scaled to 90 % width, undone between runs.
|
||||
//! `cargo run --release -p photocraft-engine --example bench_content_aware_scale [reps] [width height]`
|
||||
use std::time::Instant;
|
||||
|
||||
use photocraft_engine::Session;
|
||||
use serde_json::json;
|
||||
|
||||
fn photo_jpeg(w: u32, h: u32) -> Result<Vec<u8>, String> {
|
||||
let mut px = vec![0u8; w as usize * h as usize * 3];
|
||||
let (cx, cy, r) = (w as f32 * 0.55, h as f32 * 0.5, w.min(h) as f32 / 3.0);
|
||||
for (y, row) in px.chunks_mut(w as usize * 3).enumerate() {
|
||||
for x in 0..w as usize {
|
||||
let (fx, fy) = (x as f32 / w as f32, y as f32 / h as f32);
|
||||
let n = ((x.wrapping_mul(73_856_093) ^ y.wrapping_mul(19_349_663)) % 997) as f32 / 997.0 - 0.5;
|
||||
let blob = (-(((fx - 0.4) * 3.0).powi(2) + ((fy - 0.55) * 4.0).powi(2))).exp();
|
||||
let inside = ((x as f32 - cx).powi(2) + (y as f32 - cy).powi(2)).sqrt() < r;
|
||||
let (r0, g0, b0) = if inside { (0.85, 0.3 + 0.2 * (fx * 40.0).sin(), 0.15) } else { (0.35, 0.45, 0.55) };
|
||||
let rgb = [r0 + 0.1 * blob + n * 0.08, g0 + 0.1 * blob + n * 0.08, b0 + 0.2 * fy + n * 0.08];
|
||||
for (c, v) in rgb.into_iter().enumerate() {
|
||||
row[x * 3 + c] = (v.clamp(0.0, 1.0) * 255.0 + 0.5) as u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
let img =
|
||||
photocraft_codecs::Image::from_raw(w, h, photocraft_codecs::ChannelLayout::Rgb, photocraft_codecs::SampleType::U8, px).map_err(|e| e.to_string())?;
|
||||
photocraft_codecs::encode(&img, photocraft_codecs::Format::Jpeg, &Default::default()).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), String> {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let num = |i: usize, d: u32| args.get(i).and_then(|v| v.parse::<u32>().ok()).unwrap_or(d);
|
||||
let (reps, w, h) = (num(1, 3).clamp(1, 20) as usize, num(2, 6000).clamp(16, 20_000), num(3, 4000).clamp(16, 20_000));
|
||||
let jpeg = photo_jpeg(w, h)?;
|
||||
let doc = photocraft_io::import("photo.jpg", &jpeg).map_err(|e| e.to_string())?.document;
|
||||
let mut s = Session::new();
|
||||
s.open_document(doc, Some("photo.jpg".into()));
|
||||
let mut times = Vec::with_capacity(reps);
|
||||
for _ in 0..reps {
|
||||
let t = Instant::now();
|
||||
s.execute("edit.contentAwareScale", json!({"scaleX": 90, "scaleY": 100})).map_err(|e| e.to_string())?;
|
||||
times.push(t.elapsed().as_secs_f64() * 1000.0);
|
||||
s.execute("edit.undo", json!({})).map_err(|e| e.to_string())?;
|
||||
}
|
||||
times.sort_by(f64::total_cmp);
|
||||
let (p50, max) = (times[times.len() / 2], times[times.len() - 1]);
|
||||
println!("edit.contentAwareScale {w}x{h} to 90 % width: p50 {p50:.1} ms, max {max:.1} ms ({reps} runs)");
|
||||
Ok(())
|
||||
}
|
||||
+12
-2
@@ -1,6 +1,6 @@
|
||||
# Where PhotoCraft falls short of Photoshop
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (G9: UI scale presets done, 105–120% steps, #3222; G14: lossy DNG, raw sidecars, Camera Raw Defaults live, Calibration and Auto, CR3 assessed as not clean-room feasible; G8: PSD type on a path opens on its path and saves back into the file's `Txt2`, #7962; G11: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; adjustment clipping stays visible in compact Properties, #5231; G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G17: Help › Check for Updates and an opt-out check once per launch, DIST-220-1 partial, #5485; G10: `.asl` style libraries landed, #1051; G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; G8: paragraph direction buttons in the Paragraph panel and options bar, TYPE-218-2 partial; G1: 32-bit Hue/Saturation and Colorize as Photoshop does them, Photoshop-oracle floor 190/258, #5781; G11: compound layer properties export as separate Photoshop Set events, rename last, #8304; G11: Batch and droplets take the result at the action's Save step, so actions ending in Save As and Close work; G11: `.atn` steps that switch to another open document import, play and save back, #7103; G14: the Nikon D4 white level follows the sample depth, so 12-bit D4 NEFs no longer open 2.6 stops dark, #5978; G14: a Nikon NEF's Adobe RGB preview is read as Adobe RGB (maker-note ColorSpace 0x001E), #5987; Apply Layer Comp action mapping, #7101; G10: JPEG Options dialog landed, FILE-215-19 partial (no Matte, progressive Scans or size preview); G10: Cineon write; G10: DPX read and write, #1049, Cineon and Amiga IFF read; Classical Object Finder improvement; learned segmentation remains open; G4: named, stateful section locks and visible keyboard focus in Brush Settings; G4: independent Brush Pose tilt-axis overrides, #3825 partial; G4: Transfer Mixer-only controls, #3825 partial; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · Line truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (G2: Content-Aware Scale seam carving 1.65–3.6× faster with unchanged output, P28 row 3.3 → 1.6 s on a 4-core VM, #5236; G9: UI scale presets done, 105–120% steps, #3222; G14: lossy DNG, raw sidecars, Camera Raw Defaults live, Calibration and Auto, CR3 assessed as not clean-room feasible; G8: PSD type on a path opens on its path and saves back into the file's `Txt2`, #7962; G11: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; adjustment clipping stays visible in compact Properties, #5231; G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G17: Help › Check for Updates and an opt-out check once per launch, DIST-220-1 partial, #5485; G10: `.asl` style libraries landed, #1051; G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; G8: paragraph direction buttons in the Paragraph panel and options bar, TYPE-218-2 partial; G1: 32-bit Hue/Saturation and Colorize as Photoshop does them, Photoshop-oracle floor 190/258, #5781; G11: compound layer properties export as separate Photoshop Set events, rename last, #8304; G11: Batch and droplets take the result at the action's Save step, so actions ending in Save As and Close work; G11: `.atn` steps that switch to another open document import, play and save back, #7103; G14: the Nikon D4 white level follows the sample depth, so 12-bit D4 NEFs no longer open 2.6 stops dark, #5978; G14: a Nikon NEF's Adobe RGB preview is read as Adobe RGB (maker-note ColorSpace 0x001E), #5987; Apply Layer Comp action mapping, #7101; G10: JPEG Options dialog landed, FILE-215-19 partial (no Matte, progressive Scans or size preview); G10: Cineon write; G10: DPX read and write, #1049, Cineon and Amiga IFF read; Classical Object Finder improvement; learned segmentation remains open; G4: named, stateful section locks and visible keyboard focus in Brush Settings; G4: independent Brush Pose tilt-axis overrides, #3825 partial; G4: Transfer Mixer-only controls, #3825 partial; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color ReLine truncated
|
||||
|
||||
Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impact
|
||||
on the way to beta. This is the work list agents pick from: take the highest-ranked entry that
|
||||
@@ -306,10 +306,19 @@ what an agent can't finish alone.
|
||||
other layers gain only the strip checks. Local runs, `perf/baseline.json` not re-measured yet
|
||||
(the scorecard still shows P25 as not run); command, revision, machine and per-run numbers in
|
||||
#6206. #6205.
|
||||
- **Measured progress (2026-10-13):** Content-Aware Scale (P28) keeps its seam search across
|
||||
seams and moves no pixels. On a 4-core cloud VM (CPU, interleaved runs), the carve of P28's
|
||||
24 MP photo to 90 % width takes 556 ms instead of 2013 ms (3.6×), and the whole P28 row takes
|
||||
1.64 s instead of 3.28 s, within its 3 s budget. Smaller images on the full-resolution search
|
||||
are 1.65–2.3× faster. Output is bit-identical wherever the energy stays a number (pinned
|
||||
hashes); NaN and infinities are now deterministic. The scorecard keeps the 2026-10-05
|
||||
baseline's 954 s, which predates the per-seam energy updates and the reduced-height search,
|
||||
until the reference machine reruns it. Most of the row is now `read_region`/`write_region`
|
||||
plumbing. [Method and ranges](seam-carving-performance.md).
|
||||
- **Missing:** 22 of 25 budgeted scenarios are over budget (baseline 2026-10-05, a heavily
|
||||
loaded machine): layer move with styles 321 ms p50 against 25 ms, opacity change 276 ms
|
||||
against 20 ms, paste 12 MP 1.2 s against 100 ms, layer move on 15000×10000 16-bit 2.7 s,
|
||||
Content-Aware Scale 24 MP 954 s against 3 s, Select Subject 559 ms against 100 ms; the
|
||||
Content-Aware Scale 24 MP 954 s against 3 s (older code; now met, see above), Select Subject 559 ms against 100 ms; the
|
||||
150-layer nudge crashes the GPU compositor (P12); menus slow with thousands of layers (#2460); old machines lag (#2687).
|
||||
- **Estimate:** 200–350 h. Serial in places (compositor architecture).
|
||||
|
||||
@@ -431,6 +440,7 @@ what an agent can't finish alone.
|
||||
| 2026-10-13 | minor | G8: a Type tool click on the work path or the active shape layer's path starts type on it at the point clicked (TYPE-218-1, partial); no readiness percentage or estimate changed |
|
||||
| 2026-10-13 | minor | G14: lossy DNG (#5112), `.xmp` sidecars, Camera Raw Defaults wired, Calibration panel and Auto; CR3 sensor decode ruled out under the clean-room rule |
|
||||
| 2026-10-13 | minor | G4: Hue Jitter amount-track appearance (#3825, partial); no readiness percentage or estimate changed |
|
||||
| 2026-10-13 | minor | G2: Content-Aware Scale (P28) measured: carve 2013 → 556 ms, row 3.28 → 1.64 s on a 4-core VM, output unchanged; baseline, budgets and estimate unchanged |
|
||||
| 2026-10-13 | minor | G4: minimum inputs in Shape Dynamics and Transfer follow their Control (#3825, partial); no readiness percentage or estimate changed |
|
||||
| 2026-10-12 | minor | G5: Free Transform options bar H/V skew fields done |
|
||||
| 2026-10-12 | minor | G11: `.atn` import maps 112 events (Select and Mask, Spatter, Ripple, Crystallize, Pattern Fill, mask targeting, Step Backward, points, Bitmap) |
|
||||
|
||||
@@ -1,100 +1,160 @@
|
||||
# Content-Aware Scale performance
|
||||
|
||||
2026-10-22. Two things are recorded here: what this change saves, and a correction to the P28 row's
|
||||
recorded number, which predates the seam-search proxies and reads as hundreds of times worse than
|
||||
the code does today.
|
||||
## Seam carving keeps its search across seams (2026-10-13, #5236)
|
||||
|
||||
## The change
|
||||
Perf scenario P28 ([#211](https://github.com/storytold/photocraft/issues/211)) scales a 24 MP
|
||||
photo to 90 % width with Edit › Content-Aware Scale. Its budget is 3 s.
|
||||
|
||||
Content-Aware Scale shrinks an image by removing one seam at a time. On large images the seams are
|
||||
searched on a vertically averaged copy (`carve_width_proxy_height`), and a panel column found there
|
||||
is not an original column: each seam already removed has shifted the panel left. That was tracked
|
||||
with an `idx` map — one `usize` per proxy pixel, built up front and shifted by every seam.
|
||||
- The committed baseline (2026-10-05) records 954 s. That predates the per-seam energy updates
|
||||
and the reduced-height seam search already in `crates/algo/src/seam.rs`.
|
||||
- Before this change, the row measured 3.3 s on the machine below.
|
||||
- After it, the row measures 1.6 s and the carve itself is 3.6 times faster. The output is the
|
||||
same.
|
||||
|
||||
The original column is recoverable without the map: for the `i`-th column already taken from a row,
|
||||
`o - i` is the panel column it occupied, so the taken columns at or left of panel column `x` are
|
||||
those with `o - i <= x`, and the original column is `x` plus that count. `o - i` never decreases
|
||||
along the row's list, so that count is a binary search and the original column inserts where the
|
||||
search stopped; the rows are independent and update in parallel, like the pixel shift.
|
||||
### What changed
|
||||
|
||||
Counting it by scanning the row's list instead is a comparison per already-removed column, so its
|
||||
cost grows with the square of the seam count and a deep shrink pays it on every row and every seam.
|
||||
The binary search removes that term; what is left per removed column is one insert into a list of at
|
||||
most `seam_count` entries, i.e. an element move rather than a comparison.
|
||||
All changes are in `crates/algo/src/seam.rs`. The command, its parameters and its output are
|
||||
unchanged.
|
||||
|
||||
Output is unchanged: the same original columns reach the assembly pass, in the same order, so every
|
||||
pixel written is the pixel the map produced. The 4-channel cases below hash identically (FNV-1a over
|
||||
the output's raw `f32` bits); the 3-channel case is unchanged within timer noise.
|
||||
- **The seam search keeps its path-cost map across seams.**
|
||||
- The search is the dynamic programme of Avidan and Shamir (2007). Before, it refilled the whole
|
||||
map for every seam: for P28, 600 serial passes over about 3 M cells.
|
||||
- After a removal, `Dp::update` recomputes row by row only two kinds of pixel: those next to the
|
||||
seam, whose energies or parents changed, and those with a parent whose cost actually changed
|
||||
(compared bit for bit). Nothing else can change, so the map stays identical to a full pass.
|
||||
- On the bench images this recomputes 1.3 % of the map per seam on the reduced-height search,
|
||||
and 6–10 % on the full-resolution one. 98–99 % of the recomputed pixels do change, so the work
|
||||
is the removed seam's basin, not slack in the bounds.
|
||||
- Directions are no longer stored. The seam is traced back from the costs with the same tie
|
||||
rules (`cell`). Rows are computed by one shared, vectorised kernel (`row_costs`).
|
||||
- **The carver moves no pixels.**
|
||||
- It borrows the image, keeps each remaining pixel's source column (`u32`), and reads energy
|
||||
neighbours and the result through it.
|
||||
- A removal shifts whichever side of the seam is shorter, in three 4-byte per-pixel buffers
|
||||
(index, energy, cost). Before, it shifted everything right of the seam in up to four buffers,
|
||||
including the 16-byte RGBA pixels and, on the tracked paths, an 8-byte index.
|
||||
- The image is no longer copied.
|
||||
- **The full-resolution stages run in parallel over rows.** These are the tall-image proxy build,
|
||||
its full-resolution rebuild (runs copied between removed columns), the height pass's transposes
|
||||
(blocked) and the plain resample used by Amount.
|
||||
|
||||
## Timings
|
||||
### Exactness
|
||||
|
||||
Windows 11, Intel i5-10300H (4 cores / 8 threads), rustc 1.98.1, `--release`, default rayon pool.
|
||||
The timer covers `seam::carve_width` only: document read, tile writeback, history and the undo that
|
||||
follows the command are outside it. Each cell is the same binary run before and after the change, in
|
||||
the same session, nothing else running.
|
||||
**Inputs whose energy stays a number** (every finite image without overflow) produce output that
|
||||
is bit-identical to the previous code. These tests pin it:
|
||||
|
||||
| Case | Before (ms) | After (ms) | Change | Output |
|
||||
|---|---:|---:|---:|---|
|
||||
| 4000 × 3000 → 3600, 4 ch | 1424.7 | 1132.9 | −20.5 % | identical |
|
||||
| 6000 × 4000 → 5400, 4 ch | 3009.3 | 2559.4 | −15.0 % | identical |
|
||||
| 7200 × 5000 → 6480, 4 ch | 4352.8 | 3766.9 | −13.5 % | identical |
|
||||
- `output_bits_are_pinned`, for images under 2048 rows.
|
||||
- `tall_proxy_output_bits_are_pinned`, for the reduced-height search. It was pinned from the
|
||||
previous code before any change.
|
||||
- `carver_matches_reference`, which runs 400 random cases against the original straightforward
|
||||
implementation.
|
||||
- `incremental_dp_matches_full_dp`, which after every removal checks the kept map, the seam, the
|
||||
energy and the pixels against a recomputation from scratch.
|
||||
- The hashes of the four `bench_seam_cas` outputs.
|
||||
|
||||
Deep shrinks, where the counting scan was quadratic, on the same machine and the same binary with
|
||||
only the recording swapped (three alternating runs per side, `min`/`median`):
|
||||
**An adversarial review** compared the previous and new code side by side over more than 37 000
|
||||
generated cases. Inputs included huge values, denormals, -0.0, out-of-range protection, enlarging
|
||||
past 2× and proxy-size images. No difference appeared on any input whose energy stays a number.
|
||||
|
||||
| Case | Scan (ms) | Binary search (ms) | Change | Output |
|
||||
|---|---:|---:|---:|---|
|
||||
| 6000 × 4000 → 600, 4 ch (5 400 seams) | 16 640 / 16 757 | 13 915 / 14 066 | −16 % | identical, fnv `0f7eaa6af3cf1557` |
|
||||
| 6000 × 4000 → 3000, 4 ch (3 000 seams) | 10 617 / 10 814 | 9 936 / 10 012 | −6 % | identical, fnv `1780ee9bc9077ee9` |
|
||||
**NaN and infinities** are now deterministic on every platform:
|
||||
|
||||
The element move that remains is still linear in the row's list length, so a shrink this deep is not
|
||||
down to the index map's cost yet on four cores; a rank bitvector over the row would remove it, and is
|
||||
not in this change.
|
||||
- An energy that isn't a number is the highest energy (`+inf`). Such energies come from NaN
|
||||
samples, from infinite samples at the border or next to each other, and from overflowing
|
||||
differences.
|
||||
- NaN protection protects nothing.
|
||||
|
||||
The map was 24 MB next to a 36 MB pixel buffer at 24 MP, so the saving tracks how many bytes of row
|
||||
the seams have to shift. A three-channel case was measured too and moved inside the timer noise, so
|
||||
it is not reported as a win here. Further seam-search savings have to come from the dynamic program
|
||||
itself, not from bookkeeping.
|
||||
Before, these inputs fed NaN to the seam search. The chosen seam then depended on NaN payloads,
|
||||
which arithmetic does not keep consistently across builds or on wasm. `nan_payloads_do_not_steer_seams`
|
||||
and `infinite_samples_carve_deterministically` pin the new behaviour.
|
||||
|
||||
## P28's recorded number is stale
|
||||
**The height pass now keeps infinite protection.** It resamples the protection map; where that
|
||||
gives NaN, the map clamped to 0..=1 is resampled instead. Before, a row protected with `+inf`
|
||||
was carved away while one protected with `1.0` was kept.
|
||||
|
||||
`perf/baseline.json` records P28 (Content-Aware Scale on 24 MP to 90 % width) as 954 192 ms from the
|
||||
2026-10-05 baseline, which is why `perf/budgets.toml` carries `enforce = false` for that row. The
|
||||
seam-search proxies and the per-seam energy update landed after that capture:
|
||||
**Degenerate inputs now return early instead of panicking.** These are no channels, an empty
|
||||
width with a height change, and images or protection maps shorter than their size.
|
||||
|
||||
| Tree | 6000 × 4000 → 5400, 4 ch |
|
||||
|---|---:|
|
||||
| `f5d2bcb` (the 2026-10-05 baseline commit) | 266 039 ms |
|
||||
| `1104b6f` (main, plus this change) | 2 559 ms |
|
||||
### Measurements
|
||||
|
||||
`f5d2bcb` has no `PROXY_SHRINK_MIN_HEIGHT`: it carves at full height with a full energy recompute per
|
||||
seam. The 954 s in the baseline was that code on a machine whose recorded load average was 226–290
|
||||
on 14 cores. The two example runs above are 104× apart (266 039 ms against 2 559 ms); that is the
|
||||
seam-search core alone, and it is not the same measurement as the row's 954 s, which also includes a
|
||||
document read and writeback the timer above excludes.
|
||||
**Machine and method:**
|
||||
|
||||
The row itself is not flipped to `enforce = true` here: the budget is set for the macOS/aarch64
|
||||
machine class and only a run on that class can vouch for it. The carving core above is 2.56 s at
|
||||
24 MP on a 4-core laptop CPU; the budgeted machine is faster, but the row also includes the document
|
||||
read and writeback this measurement excludes. Flip it in the PR whose nightly run shows the row
|
||||
under 3 s, and delete this paragraph with it.
|
||||
- 4-vCPU cloud VM (Intel Xeon 2.1 GHz, Linux, no GPU), release builds.
|
||||
- The VM's speed drifts by about 20 % over time, so before and after binaries ran interleaved in
|
||||
the same window. Reported values are p50 with the [min–max] range.
|
||||
|
||||
## Reproduce
|
||||
**The carver alone:**
|
||||
|
||||
- Command: `cargo run --release -p photocraft-algo --example bench_seam_cas`.
|
||||
- Input: a synthetic photo-like RGBA image.
|
||||
- Five interleaved rounds; the output hashes were identical in every run.
|
||||
|
||||
| Case | Before | After | Speed-up |
|
||||
|---|---|---|---|
|
||||
| 24 MP to 90 % width (P28's carve, reduced-height search) | 2013 ms [1958–2149] | 556 ms [542–623] | 3.6× |
|
||||
| 24 MP to 90 % height (transposed) | 2639 ms [2617–2809] | 993 ms [967–1017] | 2.7× |
|
||||
| 5.4 MP to 90 % width (full-resolution search) | 1548 ms [1514–1648] | 677 ms [664–719] | 2.3× |
|
||||
| 1.5 MP to 70 % width (full-resolution search) | 671 ms [658–766] | 406 ms [376–421] | 1.65× |
|
||||
|
||||
**The P28 row:**
|
||||
|
||||
- Command: `perf_scenarios --cpu --only "Content-Aware Scale"`.
|
||||
- It also times reading the layer, the job and writing the result back.
|
||||
- Five interleaved rounds, n = 1 per run:
|
||||
|
||||
| P28 row | Before | After |
|
||||
|---|---|---|
|
||||
| Time | 3281 ms [3178–3364] | 1639 ms [1503–1728] |
|
||||
| Peak RSS | 1368–1386 MB | 1305–1367 MB |
|
||||
|
||||
`cargo run --release -p photocraft-engine --example bench_content_aware_scale` times the same
|
||||
command without building the UI crate. After the change, one run split as follows:
|
||||
|
||||
| Stage | Time |
|
||||
|---|---|
|
||||
| Reading the layer region | about 0.3 s |
|
||||
| The carve | about 0.5 s |
|
||||
| Writing the result back, with the undo step | about 0.2 s |
|
||||
|
||||
**Memory inside the carver** is now 12 bytes per pixel. Before, it was the image copy (4 bytes per
|
||||
channel), the energy and the stored directions, plus protection and an 8-byte index where used.
|
||||
|
||||
- The only case that uses more is a one-channel shrink without protection: 9 → 12 bytes per pixel.
|
||||
The review measured its peak 1.17× higher.
|
||||
- Every other case uses less.
|
||||
|
||||
### Limits and what is still open
|
||||
|
||||
- **The scorecard and enforcement.** The scorecard keeps showing the 2026-10-05 baseline until
|
||||
`cargo xtask perf --update-baseline` runs on the reference machine. `enforce` stays false for
|
||||
P28 until then.
|
||||
- **The rest of the P28 row** is now mostly plumbing outside the carver. `Surface::read_region`
|
||||
converts the 24 MP layer pixel by pixel on one thread, and `write_region` also runs on one
|
||||
thread.
|
||||
- **Full-resolution searches.** Enlarging still runs them, since only shrinking tall images uses
|
||||
the reduced-height search. The review measured a 24 MP 1 % enlarge going from 7.0 s to 1.8 s on a
|
||||
loaded machine. What remains per seam is the removed seam's basin in the cost map (serial, row by
|
||||
row) and the row shifts.
|
||||
- **A worst case.** When every seam hugs the right edge of a one-sided smooth ramp, the old code
|
||||
shifted nothing, but the new code's cost changes cover almost the whole map. The review measured
|
||||
that case 1.3–1.5× slower than before. No other input it tried was slower.
|
||||
- **wasm** builds run the same code on one thread.
|
||||
|
||||
## The shrink proxy's column map (2026-10-22, #8526)
|
||||
|
||||
Main had dropped the proxy search's per-pixel original-column map in favour of counting the columns
|
||||
already taken from each row (`record_removed`, −15 % at 24 MP). The carver above keeps a 4-byte
|
||||
source column per remaining pixel and returns original columns itself, so that counting step has
|
||||
nothing left to do and was removed when #5236 joined main; the tall-image output is unchanged
|
||||
(`tall_proxy_output_bits_are_pinned`).
|
||||
|
||||
Its example times the deep shrinks it was measured on:
|
||||
|
||||
```sh
|
||||
cargo build --release -p photocraft-algo --example bench_seam
|
||||
./target/release/examples/bench_seam 6000 4000 5400 4 # width height new_width channels (1..=4)
|
||||
./target/release/examples/bench_seam 6000 4000 600 4
|
||||
./target/release/examples/bench_seam 6000 4000 3000 4
|
||||
```
|
||||
|
||||
Build the base and the changed tree with separate `CARGO_TARGET_DIR`s and run the same line in both;
|
||||
the printed FNV hash of the output must match, and the millisecond figure is the row above. The
|
||||
example builds deterministic gradient-plus-detail content, so two runs of the same binary agree.
|
||||
|
||||
## Correctness and repository checks
|
||||
|
||||
`cargo test --release -p photocraft-algo seam` passes, including `carver_matches_reference`,
|
||||
`output_bits_are_pinned`, `tall_proxy_shrink_preserves_full_resolution_salient_and_protected_pixels`
|
||||
and the cancellation test. `cargo fmt --all --check` and
|
||||
`cargo clippy -p photocraft-algo --all-targets -- -D warnings` are clean. No command, UI or format
|
||||
contract changed; `Carver`'s `track` mode is still used by the enlargement path, which needs the
|
||||
original columns it was written for.
|
||||
On main with #8526 these printed fnv `0f7eaa6af3cf1557` and `1780ee9bc9077ee9`. Both changes keep
|
||||
the output unchanged, so the same hashes are expected; #8526's timings were taken on a different
|
||||
base than the ones above and are not comparable with them.
|
||||
@@ -1,6 +1,6 @@
|
||||
# PhotoCraft vs Adobe Photoshop: target-app parity
|
||||
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-22 · **Change:** minor (Help › Check for Updates and an opt-out check once per launch, DIST-220-1 partial, #5485; area type, TYPE-218-10 partial, Type scorecard 5 / 5 / 0; compound layer properties export as separate Photoshop Set events, #8304; JPEG Options dialog landed, FILE-215-19 partial; Print › Functions › Bleed through `file.print`; Content-Aware Move live preview for every selection size, TOOL-213-4 done, #6680; retouching evidence: Pattern Stamp and Background Eraser draw live, only the Mixer Brush is left of TOOL-213-7; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; shape layers take Density and Feather, TOOL-214-12 done, #5846; on-canvas corner radius widgets, TOOL-214-12; `.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-22 · **Change:** minor (Content-Aware Scale measurements added, #5236; Help › Check for Updates and an opt-out check once per launch, DIST-220-1 partial, #5485; area type, TYPE-218-10 partial, Type scorecard 5 / 5 / 0; compound layer properties export as separate Photoshop Set events, #8304; JPEG Options dialog landed, FILE-215-19 partial; Print › Functions › Bleed through `file.print`; Content-Aware Move live preview for every selection size, TOOL-213-4 done, #6680; retouching evidence: Pattern Stamp and Background Eraser draw live, only the Mixer Brush is left of TOOL-213-7; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; shape layers take Density and Feather, TOOL-214-12 done, #5846; on-canvas corner radius widgets, TOOL-214-12; `.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
The authoritative answer to "how close is PhotoCraft to Photoshop, and how much work is left". The
|
||||
one-page summary is [`ROADMAP.md`](../ROADMAP.md); the ranked work list is [`gaps.md`](gaps.md);
|
||||
@@ -369,6 +369,15 @@ The transform also corrects f32 envelope errors past coordinate 4096, including
|
||||
distances at selected pixels. The parallel path needs an additional four bytes per pixel;
|
||||
see [measurements, correctness and limits](selection-distance-performance.md).
|
||||
|
||||
2026-10-13: Content-Aware Scale keeps its seam search's path costs across seams (recomputing
|
||||
only the removed seam's basin) and no longer moves pixels. On a 4-core cloud VM (CPU, release,
|
||||
interleaved runs) the carve of P28's 24 MP photo to 90 % width takes 2013 → 556 ms (3.6×), the
|
||||
same image's height 2639 → 993 ms, and full-resolution searches 1.65–2.3× less time. The P28
|
||||
row with its document plumbing takes 3.28 → 1.64 s, within its 3 s budget. Output bits are
|
||||
unchanged wherever the energy stays a number (pinned hashes, reference comparison, a 37 000-case
|
||||
differential review); NaN and infinities are now deterministic. The committed baseline (954 s,
|
||||
older code) is unchanged until the reference machine reruns it; see [method and limits](seam-carving-performance.md).
|
||||
|
||||
**Bottom line.** Two days after 0.2.0 we had merged ~96 PRs and closed ~48 issues, but **real
|
||||
Photoshop parity is still well below 50%**. The biggest gaps are AI, missing tools, professional
|
||||
workflow depth and the plug-in ecosystem. Most fixes since 0.2.0 have passed our tests but have
|
||||
@@ -575,6 +584,7 @@ See [method, raw measurements and reproduction](five-algorithm-performance.md).
|
||||
| 2026-10-15 | minor | Print: Functions › Bleed (`file.print` / `file.printOneCopy` `bleed`, corner crop marks on the trim line, PDF and Windows paths); the Print dialog field is still missing; percentages unchanged |
|
||||
| 2026-10-13 | minor | Vector shapes: on-canvas corner radius widgets on live rectangles (TOOL-214-12); estimates unchanged |
|
||||
| 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the Pen flyout) are live toolbar tools and Frame landed, so Art History Brush is the only tool still missing; percentages unchanged |
|
||||
| 2026-10-13 | minor | Added measured Content-Aware Scale gains (P28 under its budget on a 4-core VM, not yet in the baseline); percentages and budgets unchanged |
|
||||
| 2026-10-12 | minor | Free Transform options bar H/V skew fields; percentages unchanged |
|
||||
| 2026-10-12 | minor | `.atn` import: 112 events mapped (TrueGrit Texture Supply sets play end to end); percentages unchanged |
|
||||
| 2026-10-11 | minor | Type row evidence: manual/optical kerning and the live Warp Text preview are done (TYPE-218-6/7; variable-font axes TYPE-218-4 too); the 40% estimate is not re-measured |
|
||||
|
||||
+3
-3
@@ -370,9 +370,9 @@ issue = 211
|
||||
bench = "perf_scenarios"
|
||||
row = "Content-Aware Scale 24 MP to 90 % width"
|
||||
budget_ms = 3000
|
||||
enforce = false # 954 s in the 2026-10-05 baseline, which predates the seam-search proxies: the
|
||||
# carving core is 2.6 s at 24 MP RGBA (docs/seam-carving-performance.md). Flip once a
|
||||
# budgeted-class run shows the whole row under 3 s.
|
||||
enforce = false # 954 s in the 2026-10-05 baseline, which predates the seam-search proxies. 2026-10-13: the
|
||||
# row measured 3.3 s -> 1.6 s on a 4-core VM (CPU) with the kept seam search (docs/seam-carving-performance.md).
|
||||
# Flip once a budgeted-class run shows the whole row under 3 s.
|
||||
|
||||
[[scenario]]
|
||||
id = "P29"
|
||||
|
||||
Reference in new issue
Block a user