perf(client): validate overlay reuse with source stamps and benchmark real packs

This commit is contained in:
rdbtCVS
2026-10-15 01:04:48 +01:00
committed by Ludovic Marie
parent 8177726f70
commit 1295fccd17
3 changed files with 296 additions and 100 deletions
@@ -0,0 +1,54 @@
{
"date": "2026-10-15",
"environment": "Linux x86_64/ext4/NVMe, Ryzen5 5600X, Rust1.99.0, Cargo fast",
"scope": "actual resource_root vs original wrapper/builder; warmed storage; output equivalence outside timing",
"warmups": 2,
"median_samples": 11,
"prepared_minecraft": "26.3",
"prepared_schema": 7,
"prepared_manifest_sha256": "fd03c686302748748e132ef3978b7b0bcf42024257e802985a5cc7175cc74298",
"packs": [
{
"project": "faithful-32x",
"version": "lDYpMiqk",
"version_name": "[26.3] Faithful 32x \u2013 September 2026 Release",
"publisher_page": "https://modrinth.com/resourcepack/faithful-32x/version/lDYpMiqk",
"download_url": "https://cdn.modrinth.com/data/w0TnApzs/versions/lDYpMiqk/Faithful%2032x%20-%2026.3.zip",
"zip_bytes": 13116019,
"zip_sha512": "e90ec63af7f239dbb99aa20c98b23d830e76898f65d3e31b7f0b53bb36db12dcd8c38d6930c743237c9c3db7bf708423fa1d1b2fd497dd6c281dbe216b779db9",
"asset_files": 5063,
"assets_uncompressed_bytes": 12524266,
"original_ms": 159.827,
"cold_ms": 162.711,
"hit_ms": 0.707
},
{
"project": "default-hd-128x",
"version": "rErHu3BE",
"version_name": "Default HD 128x Demo/Alpha 1.8.2.7",
"publisher_page": "https://modrinth.com/resourcepack/default-hd-128x/version/rErHu3BE",
"download_url": "https://cdn.modrinth.com/data/orfTV6nk/versions/rErHu3BE/Default%20HD%20128x%20Demo%201.8.2.7.zip",
"zip_bytes": 16876419,
"zip_sha512": "f5f9606e92b986cd9c8b8e5ff2bb52db720cc7b38e013355bdc90089e01975a08d09750ef2fd727f753d88ec3fbcd067355179b490587f667b2995f8be81640f",
"asset_files": 2318,
"assets_uncompressed_bytes": 17315416,
"original_ms": 111.501,
"cold_ms": 114.386,
"hit_ms": 0.31
},
{
"project": "fpbr",
"version": "dynf82xk",
"version_name": "support 1.21.9 and newer",
"publisher_page": "https://modrinth.com/resourcepack/fpbr/version/dynf82xk",
"download_url": "https://cdn.modrinth.com/data/nvEpbd8t/versions/dynf82xk/FPBR-Main-1.21.9-R1.3.zip",
"zip_bytes": 46737770,
"zip_sha512": "64f1bbd036e205118f1d9c49a79558db2c1356ee988fb939c0023db1967d78e1bd05047f341ce6d65355717ba7ddb1330af57edbb4d5b8713c96ae62987274c5",
"asset_files": 7001,
"assets_uncompressed_bytes": 56356903,
"original_ms": 347.639,
"cold_ms": 348.012,
"hit_ms": 0.448
}
]
}
+202 -41
View File
@@ -1,13 +1,14 @@
//! Content-validated overlay reuse. Live symlink files/subtrees need no content
//! scan; merged, extracted and copied bytes do. Topology and link targets are
//! always checked, including vanilla directories materialized by mirror.
//! Overlay reuse validated by source topology and filesystem stamps.
//! Published output is an owned cache artifact; hits do not traverse its tree.
use super::{Pack, Source, build_overlay_uncached};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::{collections::BTreeSet, fs, io, io::Read, path::Path, path::PathBuf};
#[cfg(any(test, not(unix)))]
use std::io::Read;
use std::{collections::BTreeSet, fs, io, path::Path, path::PathBuf};
// Bump when overlay/merge semantics change. Markers are disposable cache data.
const VERSION: u32 = 1;
const VERSION: u32 = 2;
#[derive(Default, Serialize, Deserialize)]
pub(super) struct Dependencies {
@@ -47,7 +48,6 @@ struct Marker {
vanilla: PathBuf,
packs: String,
dependencies: Dependencies,
output: String,
}
fn finish(hash: Sha256) -> String {
@@ -58,6 +58,7 @@ fn field(hash: &mut Sha256, bytes: &[u8]) {
hash.update((bytes.len() as u64).to_le_bytes());
hash.update(bytes);
}
#[cfg(any(test, not(unix)))]
fn content(hash: &mut Sha256, path: &Path) -> io::Result<()> {
let mut file = fs::File::open(path)?;
hash.update(file.metadata()?.len().to_le_bytes());
@@ -71,6 +72,31 @@ fn content(hash: &mut Sha256, path: &Path) -> io::Result<()> {
}
Ok(())
}
fn stamp(hash: &mut Sha256, path: &Path) -> io::Result<()> {
let meta = fs::metadata(path)?;
hash.update(meta.len().to_le_bytes());
field(hash, format!("{:?}", meta.modified()?).as_bytes());
#[cfg(unix)]
{
use std::os::unix::fs::MetadataExt;
hash.update(meta.dev().to_le_bytes());
hash.update(meta.ino().to_le_bytes());
hash.update(meta.ctime().to_le_bytes());
hash.update(meta.ctime_nsec().to_le_bytes());
}
#[cfg(not(unix))]
{
// Portable metadata lacks a change timestamp. Preserve content-based
// validation for materialized files on those platforms.
if meta.is_file() {
return content(hash, path);
}
if let Ok(created) = meta.created() {
field(hash, format!("{created:?}").as_bytes());
}
}
Ok(())
}
fn entries(path: &Path) -> io::Result<Vec<PathBuf>> {
let mut entries = fs::read_dir(path)?
.map(|e| e.map(|e| e.path()))
@@ -85,14 +111,10 @@ fn dependency_signature(path: &Path, directory: bool) -> io::Result<String> {
Err(e) => return Err(e),
Ok(meta) if directory && meta.is_dir() => {
field(&mut hash, b"directory");
for entry in entries(path)? {
field(&mut hash, entry.file_name().unwrap().as_encoded_bytes());
// mirror's decisions use the followed file type, including symlinks.
field(&mut hash, &[u8::from(entry.is_dir())]);
}
stamp(&mut hash, path)?;
}
Ok(_) if directory => field(&mut hash, b"not-directory"),
Ok(_) => content(&mut hash, path)?,
Ok(_) => stamp(&mut hash, path)?,
}
Ok(finish(hash))
}
@@ -114,7 +136,7 @@ fn needs_content(path: &Path, pack: Option<&Pack>) -> bool {
.replace('\\', "/");
// Ordinary folder resources are live Unix file symlinks. Rewrites and
// replacements at that path are visible without rebuilding. Merged JSON
// and configuration bytes are materialized and need content validation.
// and configuration bytes are materialized and need stamp validation.
relative == "pack.mcmeta"
|| super::merge_kind(&relative).is_some()
|| pack.overlays.iter().any(|overlay| {
@@ -164,11 +186,16 @@ fn tree_inner(
} else {
field(hash, b"file");
if needs_content(path, pack) {
content(hash, path)?;
#[cfg(test)]
if pack.is_none() {
return content(hash, path);
}
stamp(hash, path)?;
}
}
Ok(())
}
#[cfg(test)]
fn output_signature(out: &Path) -> io::Result<String> {
let mut hash = Sha256::new();
tree(&mut hash, out, None)?;
@@ -203,8 +230,14 @@ fn pack_signature(packs: &[Pack]) -> io::Result<String> {
field(&mut hash, format!("{:?}", pack.overlays).as_bytes());
field(&mut hash, format!("{:?}", pack.filter).as_bytes());
match &pack.source {
Source::Dir(path) => tree(&mut hash, path, Some(pack))?,
Source::Zip(path) => content(&mut hash, path)?,
Source::Dir(path) => {
field(&mut hash, absolute(path)?.as_os_str().as_encoded_bytes());
tree(&mut hash, path, Some(pack))?;
}
Source::Zip(path) => {
field(&mut hash, absolute(path)?.as_os_str().as_encoded_bytes());
stamp(&mut hash, path)?;
}
}
}
Ok(finish(hash))
@@ -242,31 +275,18 @@ pub(super) fn build(vanilla: &Path, packs: &[Pack], out: &Path) -> io::Result<()
.truncate(false)
.open(lock_path(out))?;
lock.lock()?;
// Absolute paths also prevent cwd changes from reusing relative symlinks.
// Keep root symlink aliases live, as mirror does for individual resources.
let vanilla = absolute(vanilla)?;
let packs: Vec<Pack> = packs
.iter()
.map(|pack| {
let mut pack = pack.clone();
match &mut pack.source {
Source::Dir(path) | Source::Zip(path) => {
*path = absolute(path)?;
}
}
Ok(pack)
})
.collect::<io::Result<_>>()?;
// Resolve marker identity only; preserve the builder's original link targets.
let vanilla_key = absolute(vanilla)?;
let marker_path = marker_path(out);
let signature = pack_signature(&packs);
let signature = pack_signature(packs);
if let Ok(signature) = &signature
&& let Ok(bytes) = fs::read(&marker_path)
&& let Ok(marker) = serde_json::from_slice::<Marker>(&bytes)
&& marker.version == VERSION
&& marker.vanilla == vanilla
&& marker.vanilla == vanilla_key
&& marker.packs == *signature
&& marker.dependencies.valid()
&& output_signature(out).is_ok_and(|s| s == marker.output)
&& out.is_dir()
{
return Ok(());
}
@@ -280,17 +300,16 @@ pub(super) fn build(vanilla: &Path, packs: &[Pack], out: &Path) -> io::Result<()
tracking: signature.is_ok(),
..Dependencies::default()
};
build_overlay_uncached(&vanilla, &packs, out, &mut dependencies)?;
build_overlay_uncached(vanilla, packs, out, &mut dependencies)?;
if let Ok(signature) = signature
&& dependencies.valid()
&& pack_signature(&packs).is_ok_and(|s| s == signature)
&& pack_signature(packs).is_ok_and(|s| s == signature)
{
let marker = Marker {
version: VERSION,
vanilla,
vanilla: vanilla_key,
packs: signature,
dependencies,
output: output_signature(out)?,
};
// PathBuf serialization requires UTF-8; unusual resource root names
// can still build normally without a reusable marker.
@@ -404,7 +423,7 @@ mod tests {
}
#[test]
fn directory_inputs_config_and_output_invalidate() {
fn directory_inputs_config_and_owned_output_recovery() {
let f = Fixture::new();
let resource = "assets/minecraft/lang/en_us.json";
f.write(&format!("vanilla/{resource}"), br#"{"v":"a"}"#);
@@ -461,8 +480,14 @@ mod tests {
low.filter = packs::filter_of(&serde_json::json!({"filter":{"block":[{"path":"lang"}]}}));
f.rebuild_matches(std::slice::from_ref(&low));
fs::write(out.join(resource), b"corrupt").unwrap();
// Published output is trusted; clearing the marker explicitly repairs
// a cache tree changed outside the builder.
packs::build_overlay(&f.0.join("vanilla"), std::slice::from_ref(&low), &out).unwrap();
assert_eq!(fs::read(out.join(resource)).unwrap(), b"corrupt");
fs::remove_file(&marker).unwrap();
f.rebuild_matches(std::slice::from_ref(&low));
fs::remove_file(out.join(resource)).unwrap();
fs::remove_file(&marker).unwrap();
f.rebuild_matches(std::slice::from_ref(&low));
fs::write(&marker, b"corrupt").unwrap();
f.rebuild_matches(std::slice::from_ref(&low));
@@ -584,8 +609,8 @@ mod tests {
f.rebuild_matches(std::slice::from_ref(&pack));
assert_eq!(fs::read(out.join(name)).unwrap(), b"ccc");
assert_eq!(fs::metadata(&marker).unwrap().modified().unwrap(), before);
// A changed source symlink identity is fingerprinted, and a corrupt
// output symlink is repaired even when its target bytes happen to match.
// A changed source symlink identity is fingerprinted. Output is trusted
// until its marker is cleared explicitly.
fs::remove_file(&path).unwrap();
f.write("other", b"ddd");
std::os::unix::fs::symlink(f.0.join("other"), &path).unwrap();
@@ -593,6 +618,7 @@ mod tests {
assert_eq!(fs::read(out.join(name)).unwrap(), b"ddd");
fs::remove_file(out.join(name)).unwrap();
std::os::unix::fs::symlink(f.0.join("other"), out.join(name)).unwrap();
fs::remove_file(&marker).unwrap();
f.rebuild_matches(std::slice::from_ref(&pack));
assert_eq!(fs::read_link(out.join(name)).unwrap(), path);
fs::remove_file(&path).unwrap();
@@ -908,4 +934,139 @@ mod tests {
medians[0], medians[1], medians[2]
);
}
#[cfg(unix)]
#[test]
fn relative_builder_targets_are_preserved() {
let f = Fixture::new();
f.write("vanilla/facts.json", b"[]");
let mut pack = f.dir_pack("pack");
let name = "assets/minecraft/textures/a";
f.write(&format!("pack/{name}"), b"pack");
let cwd = std::env::current_dir().unwrap();
let mut relative = PathBuf::new();
for component in cwd.components() {
if matches!(component, std::path::Component::Normal(_)) {
relative.push("..");
}
}
relative.push(f.0.strip_prefix("/").unwrap());
pack.source = Source::Dir(relative.join("pack"));
let vanilla = relative.join("vanilla");
let out = f.0.join("cached");
let reference = f.0.join("reference");
packs::build_overlay(&vanilla, std::slice::from_ref(&pack), &out).unwrap();
build_overlay_uncached(&vanilla, &[pack], &reference, &mut Dependencies::default())
.unwrap();
let expected = relative.join("pack").join(name);
assert_eq!(fs::read_link(out.join(name)).unwrap(), expected);
assert_eq!(fs::read_link(reference.join(name)).unwrap(), expected);
assert_eq!(
fs::read_link(out.join("facts.json")).unwrap(),
vanilla.join("facts.json")
);
}
#[test]
#[ignore = "requires prepared resources and real pack paths in environment"]
fn benchmark_real_resource_root() {
use std::{hint::black_box, time::Instant};
let vanilla = PathBuf::from(std::env::var("HORIZON_OVERLAY_BENCH_VANILLA").unwrap());
assert!(vanilla.join("horizon-resources.json").is_file());
let paths: Vec<PathBuf> =
serde_json::from_str(&std::env::var("HORIZON_OVERLAY_BENCH_PACKS").unwrap()).unwrap();
// The original resource_root selection/cache-key path, with its original builder.
fn original(vanilla: &Path, packs: &[Pack], cache: &Path) -> PathBuf {
let key = packs
.iter()
.map(|p| p.id.as_str())
.collect::<Vec<_>>()
.join("|");
let hash = key.bytes().fold(0xcbf2_9ce4_8422_2325u64, |h, b| {
(h ^ u64::from(b)).wrapping_mul(0x100_0000_01b3)
});
let out = cache.join(format!("{hash:016x}"));
build_overlay_uncached(vanilla, packs, &out, &mut Dependencies::default()).unwrap();
out
}
let median = |mut times: Vec<f64>| {
times.sort_by(f64::total_cmp);
times[times.len() / 2]
};
for path in paths {
let f = Fixture::new();
let pack = packs::pack(
path.to_string_lossy().into_owned(),
Text::empty(),
Source::Zip(path.clone()),
)
.unwrap();
let selected = std::slice::from_ref(&pack);
let reference_cache = f.0.join("reference");
let cached_cache = f.0.join("cached");
fs::create_dir_all(&reference_cache).unwrap();
let reference = original(&vanilla, selected, &reference_cache);
let out = packs::resource_root(&vanilla, selected, &cached_cache);
assert_ne!(out, vanilla, "resource_root must not fall back to vanilla");
assert!(marker_path(&out).exists());
let expected = output_signature(&reference).unwrap();
assert_eq!(output_signature(&out).unwrap(), expected);
for _ in 0..2 {
original(&vanilla, selected, &reference_cache);
assert_eq!(packs::resource_root(&vanilla, selected, &cached_cache), out);
}
let mut baseline = Vec::new();
let mut cold = Vec::new();
let mut hit = Vec::new();
for iteration in 0..11 {
for operation in if iteration % 2 == 0 {
[0, 1, 2]
} else {
[1, 2, 0]
} {
if operation == 1 {
fs::remove_file(marker_path(&out)).unwrap();
}
let started = Instant::now();
let result = if operation == 0 {
original(
black_box(&vanilla),
black_box(selected),
black_box(&reference_cache),
)
} else {
packs::resource_root(
black_box(&vanilla),
black_box(selected),
black_box(&cached_cache),
)
};
black_box(&result);
let ms = started.elapsed().as_secs_f64() * 1000.0;
match operation {
0 => baseline.push(ms),
1 => cold.push(ms),
_ => hit.push(ms),
}
if operation != 0 {
assert_eq!(result, out);
}
}
// Verify full materialized bytes and symlink identities outside timing.
assert_eq!(output_signature(&out).unwrap(), expected);
assert_eq!(output_signature(&reference).unwrap(), expected);
}
let baseline = median(baseline);
let cold = median(cold);
let hit = median(hit);
println!(
"real pack={} ZIP={} bytes: original={baseline:.3} ms cold={cold:.3} ms hit={hit:.3} ms speedup={:.2}x saved={:.3} ms cold_overhead={:.2}% (11 medians, 2 warmups)",
path.display(),
fs::metadata(&path).unwrap().len(),
baseline / hit,
baseline - hit,
(cold / baseline - 1.0) * 100.0
);
}
}
}
+40 -59
View File
@@ -1,69 +1,50 @@
# Reusing resource-pack overlays
`packs::build_overlay` reuses an overlay after validating a versioned sibling
JSON marker. The marker covers pack source paths/order, active overlay roots,
compiled filters, resource topology, merged inputs and the materialized output.
SHA-256 checks content rather than relying on file size or timestamps.
`packs::build_overlay` reuses a completed overlay through a versioned sibling JSON marker and persistent OS lock. Pack sources/order, overlay roots, filters, source topology and materialized vanilla inputs determine validity. The marker is removed before rebuilding and published only after a successful build and stable input checks.
On Unix, ordinary directory-pack resources and untouched vanilla resources are
live symlinks. Their bytes stay current on edits/replacements, so validation
checks topology and link targets without reading those bytes. Merged language,
sound, font and atlas JSON inputs are hashed. Vanilla directories that were
materialized by the builder are checked for additions/removals/type changes;
untouched directory symlinks stay live without a recursive vanilla scan.
On Unix, ZIPs and materialized inputs use length, modification time, device/inode and change-time stamps. Cache hits do not read archive bytes or traverse generated output. Directory packs still validate their topology; ordinary linked files and untouched vanilla subtrees remain live. Materialized vanilla directory stamps detect membership changes without listing them again. Only marker identity resolves paths; the builder retains the caller's original symlink targets and root aliases.
ZIP archives and extracted output files are fully hashed. On platforms where
`link` copies files, directory-pack contents and copied vanilla files are also
hashed. Existing merge order and filter behavior are unchanged.
On non-Unix platforms, materialized files retain content hashing because portable metadata lacks a change timestamp. That path was not runtime-tested. External folder overlays and symlink cycles retain uncached behavior. Missing/corrupt markers and a missing output root rebuild. Generated output is owned cache data: external edits to individual output files are deliberately not detected; delete the sibling marker or overlay directory to rebuild it.
A persistent sibling `.overlay-cache.lock` uses an advisory OS file lock to
serialize validation, rebuilding and publication for the same output directory.
The lock inode is never removed by the builder. The old marker is removed before
rebuilding; its replacement is renamed into place only after a successful build
and stable input checks. Missing/corrupt markers or output trigger rebuilding.
Directory packs with absolute/parent-traversal overlay paths or symlink cycles
build through the original path without publishing a reusable marker. External
overlay paths retain their previous behavior.
## Real pack measurements
## Reproduce the benchmark
The ignored test measures the actual production `resource_root` entry point against its original selection/key/build sequence. Two warmups and 11 alternating samples use identical prepared Minecraft 26.3 resources (manifest schema 7). Complete materialized output bytes and symlink identities are compared outside timing. Cold means an absent marker with warm filesystem caches, rather than cold storage.
Linux x86_64/ext4/NVMe, Ryzen 5 5600X, Rust 1.99.0, Cargo `fast`, measured 2026-10-15:
| ZIP pack | Original rebuild | Cached cold | Unchanged hit | Saved per hit |
| --- | ---: | ---: | ---: | ---: |
| Faithful 32x, 26.3 September 2026 | 159.827 ms | 162.711 ms | 0.707 ms | 159.120 ms |
| Default HD 128x demo, 1.8.2.7 | 111.501 ms | 114.386 ms | 0.310 ms | 111.191 ms |
| FPBR, 1.21.9 R1.3 | 347.639 ms | 348.012 ms | 0.448 ms | 347.191 ms |
Unchanged speedups are approximately 226x, 359x and 775x. Cold overhead on these ZIPs is 0.1–2.6%, replacing the original cache implementation's 73–79% synthetic overhead. This measures overlay assembly and cache validation, excluding scan, texture decoding, total startup and FPS.
Pack downloads were verified against publisher SHA-512 metadata. Exact versions, URLs, sizes, asset counts, hashes and prepared-manifest identity are recorded in `benchmarks/overlay-real-packs-2026-10-15.json`. Sources: [Faithful](https://modrinth.com/resourcepack/faithful-32x/version/lDYpMiqk), [Default HD](https://modrinth.com/resourcepack/default-hd-128x/version/rErHu3BE), [FPBR](https://modrinth.com/resourcepack/fpbr/version/dynf82xk). FPBR targets older 1.21.9 snapshots; it is measured as a large real 128x archive over prepared 26.3 resources, without claiming visual/version compatibility. Default HD is the publisher's free demo. Downloaded pack contents are not committed.
## Synthetic coverage
The existing fixtures contain 8,192 vanilla textures (128 MiB), 2,048 overrides (32 MiB) and 32 merged language files; equivalent directory/ZIP payloads are incompressible bytes. Eleven median samples compare identical output outside timing:
| Fixture | Original | Cached cold | Hit |
| --- | ---: | ---: | ---: |
| Directory | 108.487 ms | 126.438 ms | 7.438 ms |
| Deflated ZIP, 32.45 MiB | 155.540 ms | 155.453 ms | 0.128 ms |
| Directory, four 8 MiB files | 0.115 ms | 0.271 ms | 0.076 ms |
Directory topology scans remain a cost: the larger directory fixture adds about 17% cold overhead and gains 14.6x on hits. Tiny cold overlays add about 0.16 ms. No overall startup gain is inferred from either table.
## Reproduce and validate
```sh
CARGO_TARGET_DIR=/home/bob/Documents/horizon/target cargo test -p horizon-client --lib --profile fast packs::cache::tests::benchmark -- --ignored --nocapture --test-threads=1
export CARGO_INCREMENTAL=0
export HORIZON_OVERLAY_BENCH_VANILLA=/path/to/prepared/26.3
export HORIZON_OVERLAY_BENCH_PACKS='["/path/to/Faithful.zip","/path/to/DefaultHD.zip","/path/to/FPBR.zip"]'
cargo test -p horizon-client --lib --profile fast packs::cache::tests::benchmark_real_resource_root -- --ignored --nocapture --test-threads=1
cargo test -p horizon-client --lib --profile fast packs::cache::tests::benchmark -- --ignored --nocapture --test-threads=1 --skip benchmark_real_resource_root
cargo test -p horizon-client --lib --profile fast packs:: -- --nocapture
cargo clippy -p horizon-client --lib --tests --profile fast -- -D warnings
cargo fmt --all -- --check
```
The ignored tests compare the original builder body (dependency recording
disabled) with the production cache path on identical inputs. They warm both
paths, collect 11 repetitions and compare output signatures after each pair.
The unchanged timing includes locking and all input/output validation. Cold
means the marker is absent but filesystem caches are warm; it is not a
cold-disk measurement.
Fixtures are synthetic because prepared game assets were unavailable in this
workspace: 8,192 vanilla texture files (128 MiB), 2,048 overrides (32 MiB), and
32 merged language files with 2,000 vanilla/1,000 pack keys each. Texture bytes
are deterministic incompressible payloads approximating already-compressed PNG
data; this benchmark does not decode images. The directory and deflated ZIP
cases contain equivalent resources. A separate four-file/32 MiB directory case
checks that live content does not impose a large hashing cost.
Measured on 2026-10-14: Linux 7.2.8-zen1-2-zen x86_64, ext4/NVMe,
AMD Ryzen 5 5600X (6 cores/12 threads), Rust 1.99.0, `fast` profile.
The deflated ZIP is 34,030,189 bytes (32.45 MiB).
| Fixture | Original rebuild | Cached cold/rebuild | Unchanged validated hit | Hit speedup |
| --- | ---: | ---: | ---: | ---: |
| Directory pack | 107.129 ms | 184.868 ms | 50.484 ms | 2.12× |
| Deflated ZIP pack | 152.032 ms | 271.798 ms | 88.416 ms | 1.72× |
| Directory, four 8 MiB files | 0.112 ms | 0.316 ms | 0.122 ms | ~10 µs overhead |
The two larger cold paths are 73–79% slower because they also establish and
verify cache dependencies/output. The large-file/few-file case adds about
0.2 ms cold and 0.01 ms on an unchanged call; reading all of its live texture
bytes would instead cost tens of milliseconds, so those bytes are excluded.
The cache adds a small marker and persistent empty lock file per overlay. Hashes
stream through a 64 KiB buffer rather than retaining archive/resource contents
on cache hits. Initial/rebuilt overlays do extra validation and marker work;
tiny overlays can have a small unchanged-call overhead. Measurements cover
overlay construction only, not total startup time or frame rate. Non-Unix
copy behavior is covered in the implementation but was not runtime-tested here.
Thirteen focused tests pass, covering source edits/replacements, Unix preserved-mtime edits, pack order/removal, overlays/filters, vanilla membership, marker/output-root recovery, failed ZIP rebuilds, symlink aliases/cycles, contention and unchanged relative link targets. All three opt-in benchmarks pass; strict Clippy, formatting and whitespace checks pass. Each overlay retains a small marker and empty lock file; cache hits retain no archive byte buffer.