mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
perf(format): reuse native save writers per document
Reuse unchanged tile and blob hashes and bound retained compressed payloads. Carry the writer through native save settings while preserving save identity and exact output.
This commit is contained in:
7 files changed
+245
-37
No files matched your search
@@ -209,6 +209,8 @@ pub struct DocState {
|
||||
/// Increments on every change; UIs re-render when it moves.
|
||||
pub revision: u64,
|
||||
pub saved_revision: u64,
|
||||
/// Native save cache shared with this document's workers, released with the editing state.
|
||||
pub pcraft_cache: photocraft_io::PcraftExportCache,
|
||||
/// How much of `revision` came from view-only changes (channel eyes, targeting): pixel caches can ignore those.
|
||||
pub view_revision: u64,
|
||||
/// Area changed by the latest revision (None = assume everything changed).
|
||||
@@ -270,6 +272,7 @@ impl DocState {
|
||||
source_read_only: false,
|
||||
revision: 1,
|
||||
saved_revision: 1,
|
||||
pcraft_cache: Default::default(),
|
||||
view_revision: 0,
|
||||
last_damage: None,
|
||||
coalesce: None,
|
||||
|
||||
+110
-6
@@ -304,16 +304,20 @@ pub struct SaveStats {
|
||||
pub manifest_bytes: usize,
|
||||
}
|
||||
|
||||
type BlobHashCache = HashMap<usize, (Weak<Vec<u8>>, Hash)>;
|
||||
type TileHashCache = HashMap<(usize, SampleType), (Weak<Tile>, Hash)>;
|
||||
|
||||
#[derive(Default)]
|
||||
struct Collect<'c> {
|
||||
tiles: BTreeMap<Hash, (Arc<Tile>, SampleType)>,
|
||||
blobs: BTreeMap<Hash, Arc<Vec<u8>>>,
|
||||
hash_cache: Option<&'c mut HashMap<usize, (Weak<Tile>, Hash)>>,
|
||||
hash_cache: Option<&'c mut TileHashCache>,
|
||||
blob_hash_cache: Option<&'c mut BlobHashCache>,
|
||||
}
|
||||
|
||||
impl Sink for Collect<'_> {
|
||||
fn tile(&mut self, format: PixelFormat, tile: &Arc<Tile>) -> Hash {
|
||||
let key = Arc::as_ptr(tile) as usize;
|
||||
let key = (Arc::as_ptr(tile) as usize, format.sample);
|
||||
if let Some(cache) = self.hash_cache.as_deref_mut()
|
||||
&& let Some((w, h)) = cache.get(&key)
|
||||
&& w.upgrade().is_some_and(|t| Arc::ptr_eq(&t, tile))
|
||||
@@ -331,7 +335,19 @@ impl Sink for Collect<'_> {
|
||||
}
|
||||
|
||||
fn blob(&mut self, data: &Arc<Vec<u8>>) -> Hash {
|
||||
let key = Arc::as_ptr(data) as usize;
|
||||
if let Some(cache) = self.blob_hash_cache.as_deref_mut()
|
||||
&& let Some((w, h)) = cache.get(&key)
|
||||
&& w.upgrade().is_some_and(|b| Arc::ptr_eq(&b, data))
|
||||
{
|
||||
let h = h.clone();
|
||||
self.blobs.entry(h.clone()).or_insert_with(|| data.clone());
|
||||
return h;
|
||||
}
|
||||
let h = hash_bytes(data);
|
||||
if let Some(cache) = self.blob_hash_cache.as_deref_mut() {
|
||||
cache.insert(key, (Arc::downgrade(data), h.clone()));
|
||||
}
|
||||
self.blobs.entry(h.clone()).or_insert_with(|| data.clone());
|
||||
h
|
||||
}
|
||||
@@ -365,16 +381,25 @@ pub const DEFAULT_REVERIFY_BUDGET: u64 = 16 * 1024 * 1024;
|
||||
/// [`Self::set_reverify_budget`]). Over enough saves every object is read again, and a damaged
|
||||
/// one is rewritten.
|
||||
pub struct PcraftWriter {
|
||||
hash_cache: HashMap<usize, (Weak<Tile>, Hash)>,
|
||||
hash_cache: TileHashCache,
|
||||
blob_hash_cache: BlobHashCache,
|
||||
/// Compressed objects by bundle path (ZIP mode).
|
||||
compressed: HashMap<String, Arc<Vec<u8>>>,
|
||||
compressed_budget: usize,
|
||||
verified_directory: Option<DirectoryVerificationCache>,
|
||||
reverify_budget: u64,
|
||||
}
|
||||
|
||||
impl Default for PcraftWriter {
|
||||
fn default() -> Self {
|
||||
Self { hash_cache: HashMap::new(), compressed: HashMap::new(), verified_directory: None, reverify_budget: DEFAULT_REVERIFY_BUDGET }
|
||||
Self {
|
||||
hash_cache: HashMap::new(),
|
||||
blob_hash_cache: HashMap::new(),
|
||||
compressed: HashMap::new(),
|
||||
compressed_budget: usize::MAX,
|
||||
verified_directory: None,
|
||||
reverify_budget: DEFAULT_REVERIFY_BUDGET,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,10 +754,18 @@ impl PcraftWriter {
|
||||
self.reverify_budget = bytes;
|
||||
}
|
||||
|
||||
/// Cap compressed payload capacity retained between ZIP saves. Clears the previous payload
|
||||
/// cache; tile hashes remain reusable. The default is unbounded; `0` retains no payloads.
|
||||
pub fn set_compressed_cache_budget(&mut self, bytes: usize) {
|
||||
self.compressed_budget = bytes;
|
||||
self.compressed.clear();
|
||||
}
|
||||
|
||||
fn prepare(&mut self, doc: &Document, opts: &SaveOptions) -> Result<Prepared> {
|
||||
self.hash_cache.retain(|_, (w, _)| w.strong_count() > 0);
|
||||
self.blob_hash_cache.retain(|_, (w, _)| w.strong_count() > 0);
|
||||
convert::check_nesting(&doc.layers)?;
|
||||
let mut c = Collect { hash_cache: Some(&mut self.hash_cache), ..Default::default() };
|
||||
let mut c = Collect { hash_cache: Some(&mut self.hash_cache), blob_hash_cache: Some(&mut self.blob_hash_cache), ..Default::default() };
|
||||
let document = convert::doc_m(doc, &mut c);
|
||||
let mut previews = Vec::new();
|
||||
if let Some(t) = &opts.thumbnail {
|
||||
@@ -777,6 +810,7 @@ impl PcraftWriter {
|
||||
z.add(name, data)?;
|
||||
}
|
||||
let mut next = HashMap::with_capacity(p.objects.len());
|
||||
let mut cached_bytes = 0usize;
|
||||
// New objects are compressed on all cores first (zstd dominates a full save).
|
||||
let todo: Vec<(&String, &Object)> = p.objects.iter().filter(|(path, _)| !self.compressed.contains_key(*path)).collect();
|
||||
let mut fresh: HashMap<&String, Arc<Vec<u8>>> = par_compress(&todo)?.into_iter().collect();
|
||||
@@ -797,7 +831,10 @@ impl PcraftWriter {
|
||||
}
|
||||
};
|
||||
z.add(path, &data)?;
|
||||
next.insert(path.clone(), data);
|
||||
if data.capacity() <= self.compressed_budget.saturating_sub(cached_bytes) {
|
||||
cached_bytes += data.capacity();
|
||||
next.insert(path.clone(), data);
|
||||
}
|
||||
}
|
||||
self.compressed = next;
|
||||
Ok((z.finish()?, stats))
|
||||
@@ -945,6 +982,73 @@ impl PcraftWriter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn tile_hash_cache_keeps_sample_byte_order_in_its_identity() {
|
||||
let mut cache = HashMap::new();
|
||||
let mut surface = photocraft_raster::Surface::new(PixelFormat::RGBA8);
|
||||
surface.write_pixel(0, 0, &[0.1, 0.2, 0.3, 1.0]);
|
||||
let tile = surface.tile(photocraft_geom::TileCoord::new(0, 0)).unwrap();
|
||||
let mut collect = Collect { hash_cache: Some(&mut cache), ..Default::default() };
|
||||
for sample in [SampleType::U8, SampleType::U16] {
|
||||
let format = if sample == SampleType::U8 { PixelFormat::RGBA8 } else { PixelFormat::new(photocraft_color::ColorMode::Grayscale, sample, true) };
|
||||
assert_eq!(collect.tile(format, tile), hash_bytes(&tile_le(tile, sample)));
|
||||
}
|
||||
drop(collect);
|
||||
assert_eq!(cache.len(), 2);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn blob_hash_cache_tracks_arc_identity_without_retaining_payloads() {
|
||||
let mut cache = HashMap::new();
|
||||
let original = Arc::new(vec![1, 2, 3]);
|
||||
let weak = Arc::downgrade(&original);
|
||||
let mut collect = Collect { blob_hash_cache: Some(&mut cache), ..Default::default() };
|
||||
let hash = collect.blob(&original);
|
||||
assert_eq!(collect.blob(&original), hash);
|
||||
let mut edited = original.clone();
|
||||
Arc::make_mut(&mut edited)[0] = 7;
|
||||
assert_eq!(collect.blob(&edited), hash_bytes(&[7, 2, 3]));
|
||||
assert_ne!(collect.blob(&edited), hash);
|
||||
drop(collect);
|
||||
assert_eq!(cache.len(), 2);
|
||||
drop(original);
|
||||
assert!(weak.upgrade().is_none());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn compressed_cache_budget_limits_retained_capacity_without_changing_bytes() {
|
||||
use photocraft_doc::{Layer, LayerContent};
|
||||
use photocraft_geom::Size;
|
||||
use photocraft_raster::Surface;
|
||||
|
||||
let mut doc = Document::new("cache", Size::new(257, 1), photocraft_color::ColorMode::Rgb, SampleType::U8);
|
||||
let mut surface = Surface::new(doc.pixel_format());
|
||||
surface.write_pixel(0, 0, &[0.2, 0.4, 0.6, 1.0]);
|
||||
surface.write_pixel(256, 0, &[0.6, 0.4, 0.2, 1.0]);
|
||||
doc.layers.push(Layer::new("pixels", LayerContent::Raster(surface)));
|
||||
let mut writer = PcraftWriter::new();
|
||||
let (expected, _) = writer.save_zip(&doc, &SaveOptions::default()).unwrap();
|
||||
let budget = writer.compressed.values().map(|v| v.capacity()).min().unwrap();
|
||||
writer.set_compressed_cache_budget(budget);
|
||||
assert!(writer.compressed.is_empty());
|
||||
let (bytes, _) = writer.save_zip(&doc, &SaveOptions::default()).unwrap();
|
||||
assert_eq!(bytes, expected);
|
||||
assert!(writer.compressed.values().map(|v| v.capacity()).sum::<usize>() <= budget);
|
||||
assert!(!writer.compressed.is_empty());
|
||||
let retained = writer.compressed.len();
|
||||
let (bytes, stats) = writer.save_zip(&doc, &SaveOptions::default()).unwrap();
|
||||
assert_eq!(bytes, expected);
|
||||
assert_eq!(stats.tiles_reused, retained);
|
||||
writer.set_compressed_cache_budget(0);
|
||||
let (bytes, stats) = writer.save_zip(&doc, &SaveOptions::default()).unwrap();
|
||||
assert_eq!(bytes, expected);
|
||||
assert_eq!(stats.tiles_reused, 0);
|
||||
assert!(writer.compressed.is_empty());
|
||||
}
|
||||
|
||||
#[cfg(all(test, unix))]
|
||||
#[test]
|
||||
fn gc_pinned_directory_handles_resist_subdirectory_swap() {
|
||||
|
||||
+10
-1
@@ -52,8 +52,10 @@ mod multichannel_map;
|
||||
mod ora;
|
||||
pub use ora::losses as ora_losses;
|
||||
pub mod pattern_map;
|
||||
mod pcraft_cache;
|
||||
pub mod pdf;
|
||||
mod pdn;
|
||||
pub use pcraft_cache::PcraftExportCache;
|
||||
pub mod pixels;
|
||||
mod psd_export;
|
||||
mod psd_import;
|
||||
@@ -191,6 +193,8 @@ pub struct ExportOptions {
|
||||
/// The path of the document's own file, which linked smart objects that PSD/PSB and layered
|
||||
/// TIFF embed are resolved against ([`doc_path::resolve`]).
|
||||
pub document_path: Option<std::path::PathBuf>,
|
||||
/// Reuse one cache per open document for native saves; other formats ignore it.
|
||||
pub pcraft_cache: Option<PcraftExportCache>,
|
||||
}
|
||||
|
||||
impl Default for ExportOptions {
|
||||
@@ -204,6 +208,7 @@ impl Default for ExportOptions {
|
||||
image_previews: true,
|
||||
psd_maximize_compatibility: true,
|
||||
document_path: None,
|
||||
pcraft_cache: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,7 +418,11 @@ fn export_stages(doc: &Document, name_or_ext: &str, opts: &ExportOptions, ctl: &
|
||||
ctl.check().map_err(|_| IoError::Cancelled)?;
|
||||
ctl.progress(PCRAFT_PREVIEWS_DONE);
|
||||
let previews = photocraft_format::SaveOptions { thumbnail, composite };
|
||||
return Ok(ExportResult { bytes: photocraft_format::save_to_bytes(doc.as_ref(), &previews)?, warnings: Vec::new() });
|
||||
let bytes = match &opts.pcraft_cache {
|
||||
Some(cache) => cache.encode(doc.as_ref(), &previews)?,
|
||||
None => photocraft_format::save_to_bytes(doc.as_ref(), &previews)?,
|
||||
};
|
||||
return Ok(ExportResult { bytes, warnings: Vec::new() });
|
||||
}
|
||||
if ext == "psd" || ext == "psb" {
|
||||
let o = PsdExportOptions {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//! Per-document native export cache; file writes and save identity stay with the caller.
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use photocraft_doc::Document;
|
||||
use photocraft_format::{PcraftWriter, SaveOptions};
|
||||
|
||||
/// Shared native export cache. Clones reuse tile hashes and up to 64 MiB of compressed payloads;
|
||||
/// dropping the last clone releases it, including when a document closes after a save worker.
|
||||
#[derive(Clone)]
|
||||
pub struct PcraftExportCache(Arc<Mutex<PcraftWriter>>);
|
||||
|
||||
impl Default for PcraftExportCache {
|
||||
fn default() -> Self {
|
||||
let mut writer = PcraftWriter::new();
|
||||
writer.set_compressed_cache_budget(64 << 20);
|
||||
Self(Arc::new(Mutex::new(writer)))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for PcraftExportCache {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str("PcraftExportCache")
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for PcraftExportCache {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl PcraftExportCache {
|
||||
pub(crate) fn encode(&self, doc: &Document, opts: &SaveOptions) -> photocraft_format::Result<Vec<u8>> {
|
||||
self.0.lock().unwrap_or_else(std::sync::PoisonError::into_inner).save_zip(doc, opts).map(|(bytes, _)| bytes)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{ExportOptions, export};
|
||||
use photocraft_color::{ColorMode, SampleType};
|
||||
use photocraft_doc::{Layer, LayerContent};
|
||||
use photocraft_geom::Size;
|
||||
use photocraft_raster::Surface;
|
||||
|
||||
#[test]
|
||||
fn cached_exports_reuse_tiles_and_preserve_edits_and_save_as() {
|
||||
for depth in SampleType::ALL {
|
||||
let mut doc = Document::new("first.pcraft", Size::new(2, 1), ColorMode::Rgb, depth);
|
||||
let mut surface = Surface::new(doc.pixel_format());
|
||||
surface.write_pixel(0, 0, &[0.2, 0.4, 0.6, 1.0]);
|
||||
doc.layers.push(Layer::new("photo", LayerContent::Raster(surface)));
|
||||
let cache = PcraftExportCache::default();
|
||||
let options = ExportOptions { pcraft_cache: Some(cache.clone()), ..Default::default() };
|
||||
let first = export(&doc, "first.pcraft", &options).unwrap();
|
||||
assert_eq!(photocraft_format::load_from_bytes(&first.bytes).unwrap(), doc);
|
||||
let (_, stats) = cache.0.lock().unwrap().save_zip(&doc, &SaveOptions::default()).unwrap();
|
||||
assert_eq!(stats.tiles_reused, stats.tiles_total);
|
||||
assert_eq!(stats.tiles_written, 0);
|
||||
doc.layers[0].surface_mut().unwrap().write_pixel(0, 0, &[0.8, 0.3, 0.1, 1.0]);
|
||||
let next = export(&doc, "second.pcraft", &options).unwrap();
|
||||
let mut expected = doc.clone();
|
||||
expected.name = "second.pcraft".into();
|
||||
assert_eq!(photocraft_format::load_from_bytes(&next.bytes).unwrap(), expected);
|
||||
assert_eq!(next.bytes, export(&doc, "second.pcraft", &ExportOptions::default()).unwrap().bytes);
|
||||
let weak = Arc::downgrade(&cache.0);
|
||||
drop(options);
|
||||
drop(cache);
|
||||
assert!(weak.upgrade().is_none());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,6 +287,8 @@ pub struct ExportSettings {
|
||||
/// The path of the document's own file, which linked smart objects that PSD/PSB embed are
|
||||
/// resolved against ([`photocraft_io::ExportOptions::document_path`]).
|
||||
pub document_path: Option<std::path::PathBuf>,
|
||||
/// Native save cache owned by the open document; exports without one remain one-shot.
|
||||
pub pcraft_cache: Option<photocraft_io::PcraftExportCache>,
|
||||
}
|
||||
|
||||
impl Default for ExportSettings {
|
||||
@@ -303,6 +305,7 @@ impl Default for ExportSettings {
|
||||
embed_icc: true,
|
||||
embed_metadata: true,
|
||||
document_path: None,
|
||||
pcraft_cache: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,6 +330,7 @@ impl ExportSettings {
|
||||
opts.image_previews = self.image_previews;
|
||||
opts.psd_maximize_compatibility = self.psd_maximize_compatibility;
|
||||
opts.document_path = self.document_path.clone();
|
||||
opts.pcraft_cache = self.pcraft_cache.clone();
|
||||
opts
|
||||
}
|
||||
}
|
||||
@@ -1606,6 +1610,7 @@ impl PhotocraftApp {
|
||||
settings.webp_lossless = e.webp_lossless.unwrap_or(settings.webp_lossless);
|
||||
settings.webp_quality = e.webp_quality.map(|q| q.min(100));
|
||||
settings.document_path = st.path.as_deref().map(std::path::PathBuf::from);
|
||||
settings.pcraft_cache = Some(st.pcraft_cache.clone());
|
||||
}
|
||||
settings
|
||||
}
|
||||
|
||||
@@ -30,6 +30,16 @@ fn identity(app: &PhotocraftApp) -> (String, Option<String>, u64, u64) {
|
||||
(st.doc.name.clone(), st.path.clone(), st.revision, st.saved_revision)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_settings_share_only_the_open_documents_native_cache() {
|
||||
let mut app = app();
|
||||
let first = app.save_settings().io_options().pcraft_cache.unwrap();
|
||||
assert_eq!(first, app.session.active().unwrap().pcraft_cache);
|
||||
assert_eq!(first, app.save_settings().io_options().pcraft_cache.unwrap());
|
||||
app.run("file.new", json!({"width": 2, "height": 2})).unwrap();
|
||||
assert_ne!(first, app.save_settings().io_options().pcraft_cache.unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_document_psd_and_subsequent_save_as_adopt_the_written_file_name() {
|
||||
for depth in [8, 16, 32] {
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
# Rust Zstandard workspace reuse
|
||||
# Native save writer reuse
|
||||
|
||||
Removed locally: complete layered-photo ZIP save changes range from -1.9% to +0.2%. An apparent 4.8% gain in one 16-bit APFS directory save failed independent confirmation, which was 3.2% slower. The other directory cases are neutral. There is no repeatable meaningful whole-operation gain, so store.rs, including its added workspace tests and synthetic microbenchmark, is restored byte for byte to main. The original local tip is recoverable at refs/archive/perf/zstd-workspaces-PRE-LAYERED-REVIEW. Only the performance report remains different from main on this branch.
|
||||
Each open document keeps a writer through the ordinary save settings. Unchanged tile and
|
||||
blob identities reuse weakly cached hashes; compressed payload capacity retained between
|
||||
saves is capped at 64 MiB. The last cache owner releases it. Other formats ignore the cache,
|
||||
and one-shot exports still work. Save As names, previews, cancellation, atomic writes and
|
||||
saved revisions keep their existing behavior. Tile hash identity includes sample depth.
|
||||
|
||||
Measured on 2026-10-19 against frozen main `d95fdf3181c01ad41e95456091a394b105a9afb2`, independently for each branch. Apple M4 Max, 16 CPUs, 128 GiB, macOS arm64, rustc 1.99.1. Release O3, LTO off, 16 codegen units, debug off; builds/tests at nice 10 with warm caches. Timed operations run at normal priority without concurrent builds or profiling. Persistent processes alternate execution order after a warmup. Time change compares the two medians; paired bootstrap intervals from these small samples describe variation, not guarantees.
|
||||
The format writer's compressed-cache limit defaults to unbounded for existing callers.
|
||||
The UI selects 64 MiB. This is retained memory that a one-shot save would release; it does
|
||||
not cap current-save scratch or ZIP output, and it does not reduce bytes written to disk.
|
||||
|
||||
CC0 Pixls P1000475.RW2 supplies a 6000 x 4000 centre crop (24 MP, no resampling); IMG_4059.CR2 supplies the native 4000 x 3000 city photograph. U8/U16/F32 documents retain ProPhoto RGB; F32 derives from 16-bit development and is not native HDR. No generated noise, repeated ramps, enlarged charts or duplicated photo layers are timed. Source pins and attribution remain in the existing corpus.
|
||||
## Measurements
|
||||
|
||||
Each constructed photo edit has four visible layers: the real raster photograph; global Levels (black 2/255, white 250/255, gamma 1.08); Curves with master points (0,0), (0.25,0.22), (0.5,0.52), (0.75,0.80), (1,1) plus red midtone 0.5→0.515; and foreground Levels (gamma 1.15) through a smooth grayscale mask fading from zero to one over 35–75% of image height. These are authored benchmark edits of licensed photos, not Photoshop-authored oracle files. Saved previews were inspected.
|
||||
Release build on Apple M4 Max. CC0 Pixls foliage (24 MP, unscaled crop) and city (12 MP,
|
||||
native size) edits contain a photograph, global Levels, Curves and masked foreground Levels.
|
||||
ProPhoto RGB is retained. U8/U16/F32 are tested; F32 derives from developed U16 samples.
|
||||
Two upstream PSD designs add authored layered-file coverage. No generated noise is timed.
|
||||
|
||||
Complete full-resolution CPU rendering and fresh ZIP saves use seven alternating pairs. Thumbnail rendering, hashing and document equality are outside timers. Every render must match main float bit for float bit; every save must match main byte for byte and reload to the complete source document. Directory saves also use seven pairs and fresh directories with a fresh writer; an independent confirmation uses nine pairs. Directory creation/removal, output hashing and full reload equality are outside the timer. These directory timings include APFS writes and fsync, unlike the in-memory ZIP timings. These are CPU/core measurements, not GPU or browser performance claims.
|
||||
The table uses seven alternating pairs after warmup and includes thumbnail/composite
|
||||
rendering, encoding, APFS atomic writes, fsync and rename. Hashing, reload equality and file
|
||||
removal are outside timers. Intervals are paired bootstrap 95% descriptions of these samples.
|
||||
The parent's production path is the same as main. Each small edit changes one real-photo tile.
|
||||
|
||||
| Document | Operation | Main ms | Branch ms | Change | Paired 95% interval |
|
||||
| Document | Operation | Main ms | Parent ms | Retained ms | Change vs parent |
|
||||
|---|---|---:|---:|---:|---:|
|
||||
| panasonic-8 | save | 167.893 | 165.025 | -1.7% | -5.3..-0.6% |
|
||||
| panasonic-16 | save | 371.857 | 364.765 | -1.9% | -3.0..+1.8% |
|
||||
| panasonic-32 | save | 641.312 | 635.064 | -1.0% | -3.0..+4.3% |
|
||||
| canon-8 | save | 93.469 | 93.592 | +0.1% | -0.8..+1.0% |
|
||||
| canon-16 | save | 185.048 | 185.385 | +0.2% | -0.2..+4.3% |
|
||||
| canon-32 | save | 327.223 | 326.519 | -0.2% | -0.2..+2.4% |
|
||||
| panasonic-8 | save-dir | 5537.227 | 5534.940 | -0.0% | -7.1..+2.2% |
|
||||
| panasonic-16 | save-dir | 7077.156 | 6739.019 | -4.8% | -5.3..-0.3% |
|
||||
| canon-32 | save-dir | 3979.360 | 3974.353 | -0.1% | -0.9..+1.6% |
|
||||
| panasonic-16 | save-dir (confirm) | 6483.861 | 6691.230 | +3.2% | +1.5..+9.2% |
|
||||
| 24 MP foliage, U16 | save-first-disk | 966.0 | 966.0 | 984.9 | +2.0% (-8.5..+2.7) |
|
||||
| 24 MP foliage, U16 | save-repeat-disk | 983.0 | 983.0 | 651.8 | -33.7% (-35.8..-30.9) |
|
||||
| 24 MP foliage, U16 | save-edit-disk | 968.6 | 968.6 | 640.1 | -33.9% (-34.2..-33.0) |
|
||||
| 12 MP city, U8 | save-first-disk | 660.8 | 660.8 | 621.6 | -5.9% (-7.5..+1.1) |
|
||||
| 12 MP city, U8 | save-repeat-disk | 658.9 | 658.9 | 496.6 | -24.6% (-26.4..-18.8) |
|
||||
| 12 MP city, U8 | save-edit-disk | 628.4 | 628.4 | 502.2 | -20.1% (-26.3..-17.8) |
|
||||
|
||||
The earlier eight flat-photo/authored-design comparisons were also close to neutral for fresh ZIP saves. All candidate bundles and directory contents match main byte for byte. Retention required a repeatable improvement of at least 3% in a complete operation, with a paired interval excluding zero and no material new regression. Kernel-only differences do not satisfy that criterion.
|
||||
An independent nine-pair U16 first-save check changed its median delta from +2.0% to -5.9%,
|
||||
with both intervals crossing zero; no repeatable first-save regression or speedup is established.
|
||||
Initial in-memory repeated-export medians across six photo/depth cases improve 18–47%.
|
||||
The independent disk runs confirm 20–34% gains for repeated and small-edit saves.
|
||||
Peak RSS is close to main; the retained-payload idle-memory cost still applies.
|
||||
|
||||
Post-removal affected checks passed: three RGB ZIP depth round trips; directory round trips across the existing mode/depth matrix; ZIP incremental saves; directory incremental saves and garbage collection (six tests total). Strict all-target format Clippy, affected format WASM and formatting checks also passed. No unrelated full-suite or synthetic timing run was repeated.
|
||||
|
||||
Harness, raw observations, exact inputs and binary hashes: `.local/perf-followup-261019/` (ignored local evidence). Previous flat-photo and authored-design results remain in `.local/perf-real-261019/`. Nothing was pushed and no PR was changed.
|
||||
|
||||
## Earlier split validation
|
||||
|
||||
These checks passed when the split was prepared; they were not all rerun for this benchmark review. Current affected checks are listed above where production code changed.
|
||||
|
||||
- `cargo test -p photocraft-format --locked`: passed (147 passed, 1 ignored).
|
||||
- `cargo clippy -p photocraft-format --locked --all-targets -- -D warnings`: passed.
|
||||
- `cargo xtask layers`: passed.
|
||||
- `cargo check -p photocraft-format --locked --target wasm32-unknown-unknown`: passed.
|
||||
Every output is byte-identical to the baseline and reloads to the complete source document.
|
||||
Scoped tests cover cache capacity/output, weak identities, sample depth, Save As, lifetime and
|
||||
save-settings forwarding. Existing save-identity tests cover failed encoding/writing and copies.
|
||||
Reference in new issue
Block a user