From bc4239b2b2e3e29997a9e5b40ab2b40d5e343b8b Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Tue, 10 Nov 2026 11:55:47 -0600 Subject: [PATCH] feat: switch-from-empty case for the materialization benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit switch_from_empty rests on a view where every tracked file is absent (untimed setup switch) and times the switch to the full view: maximal pure materialize work through the switch entry point — every tracked file rendered and written, no deletions, no revert machinery. Measured many-files: 887 ms graph / 872 ms span, comparable to switch_many — the switch machinery itself, not the write volume, dominates at this fixture size. --- .../examples/materialize_bench.rs | 18 ++++++++++++++++++ tools/materialize-bench/run.py | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/atomic-repository/examples/materialize_bench.rs b/atomic-repository/examples/materialize_bench.rs index 9a311003..27bb3a74 100644 --- a/atomic-repository/examples/materialize_bench.rs +++ b/atomic-repository/examples/materialize_bench.rs @@ -28,6 +28,7 @@ const CASES: &[&str] = &[ "switch_one_back", "switch_many_forward", "switch_many_back", + "switch_from_empty", ]; /// Zero-based fixture index of a generated `files/file_NNNN.txt` path. @@ -229,6 +230,16 @@ impl Fixture { golden.insert("dev".into(), capture(&contents)?); repo.create_view_from("bench-near", "dev")?; repo.create_view_from("bench-far", "dev")?; + // A view where every tracked file is absent: the far end of the + // switch spectrum (the existing near/far views differ by lines). + repo.create_view_from("bench-empty", "dev")?; + repo.switch_view(wc, "bench-empty")?; + for file in &golden["dev"] { + fs::remove_file(root.join(&file.path))?; + } + record(&repo, "synthetic empty view", &mut tick)?; + repo.switch_view(wc, "dev")?; + repo.materialize(wc)?; repo.switch_view(wc, "bench-near")?; let mut near = contents.clone(); near[0][0] = "near view: one changed line\n".into(); @@ -420,6 +431,13 @@ fn sample(fixture: &mut Fixture, case: &str, iteration: usize) -> Result if case == "render_reopened" { drop(fixture.repo.take()); } + if case == "switch_from_empty" { + // Untimed setup: rest on the empty view so the timed switch carries + // the full materialization — every tracked file rendered and written, + // nothing deleted. Pure materialize work, no revert machinery. + let repo = fixture.repo.as_mut().unwrap(); + repo.switch_view(repo.require_working_copy_id()?, "bench-empty")?; + } // Partial path sets are cloned outside the timed region. let partial_paths = fixture.partial_paths.clone(); let prefix = fixture.prefix.clone(); diff --git a/tools/materialize-bench/run.py b/tools/materialize-bench/run.py index 6392a6a0..00fda5c8 100644 --- a/tools/materialize-bench/run.py +++ b/tools/materialize-bench/run.py @@ -21,7 +21,8 @@ } CASES = ('render_session', 'render_reopened', 'materialize_noop', 'materialize_missing', 'materialize_paths_noop', 'materialize_paths_missing', 'materialize_prefix_missing', - 'switch_one_forward', 'switch_one_back', 'switch_many_forward', 'switch_many_back') + 'switch_one_forward', 'switch_one_back', 'switch_many_forward', 'switch_many_back', + 'switch_from_empty') def validate_report(report, iterations):