Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(bench): stabilize list-bench fixture and record thread-count findings (#2683)
Maximilian Roose10a1b7617c7
diff --git a/src/main.rs b/src/main.rsindex bd2d00067..2856c9231 100644--- a/src/main.rs+++ b/src/main.rs@@ -1037,6 +1037,14 @@ fn handle_remove_command(args: RemoveArgs, yes: bool) -> anyhow::Result<()> {/// (often blocked on pipe reads) alongside occasional network requests. 2x CPU/// cores lets threads waiting on I/O overlap with compute work without excessive/// context-switch overhead.+///+/// 3x CPU was benchmarked against `divergent_branches/warm` (branch-heavy) and+/// `worktree_scaling/warm/8` (worktree-heavy) on packed fixtures. 3x is at or+/// within noise of the optimum on both workloads; 2x trails by 0-5% (divergent:+/// 259ms vs 257ms, CIs overlap; worktree: 86.6ms vs 82.4ms, ~5% gap). 4x+/// regresses on branch-heavy workloads. We stay at 2x because the win is small+/// in absolute terms (≤ 5ms) and 2x has been validated in production across+/// hardware we haven't benchmarked.pub(crate) fn rayon_thread_count() -> usize {std::thread::available_parallelism().map(|n| n.get() * 2)diff --git a/tests/helpers/wt-perf/src/lib.rs b/tests/helpers/wt-perf/src/lib.rsindex fd4b46c66..bb7b4d9a3 100644--- a/tests/helpers/wt-perf/src/lib.rs+++ b/tests/helpers/wt-perf/src/lib.rs@@ -163,6 +163,18 @@ pub fn create_repo_at(config: &RepoConfig, base_path: &Path) {run_git(&repo_path, &["init", "-b", "main"]);run_git(&repo_path, &["config", "user.name", "Benchmark"]);run_git(&repo_path, &["config", "user.email", "[email protected]"]);+ // Disable all background auto-maintenance: rapid commits in the+ // build loop trigger detached `git gc` / `git maintenance` runs+ // whose pack-and-prune steps race the foreground `git add` /+ // `git commit`, producing intermittent "invalid object ..." /+ // "unable to create temporary file" / "failed to insert into+ // database" failures partway through a 500-commit fixture. Modern+ // git enables both `gc.auto` (loose-object threshold) and+ // `maintenance.auto` (the post-command hook scheduler) by default,+ // so we have to silence both.+ run_git(&repo_path, &["config", "gc.auto", "0"]);+ run_git(&repo_path, &["config", "gc.autoPackLimit", "0"]);+ run_git(&repo_path, &["config", "maintenance.auto", "false"]);// Create initial file structurelet num_files = config.files.max(1);@@ -230,6 +242,14 @@ pub fn create_repo_at(config: &RepoConfig, base_path: &Path) {// Set up fake remote for default branch detectionsetup_fake_remote(&repo_path);++ // Pack objects and write the commit-graph once, after all refs+ // exist. Auto-maintenance is disabled (see above), so we do this+ // explicitly — the goal is a mature-repo shape: one packfile, a+ // commit-graph, no loose-object lookup overhead. Without this,+ // benches measure cold-clone-shaped repos, which exaggerates+ // per-object I/O cost relative to what users see on day-N repos.+ run_git(&repo_path, &["gc"]);}/// Add worktrees to an existing repo using worktrunk naming convention.