Skip to content

Inspect Worktree ownership with fewer git processes to shorten macOS CI - #857

Merged
JacobStephens2 merged 2 commits into
mainfrom
issue-846
Oct 20, 2026
Merged

JacobStephens2 merged 2 commits into
mainfrom
issue-846

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

macOS shards spend ~33 s building and 990–1220 s running tests (main run 39337614995). Locally, Run tests are bound by spawning processes, and ~82% of the spawns are git commands from Worktree ownership inspection. That inspection runs at least twice around every ordinary Worktree operation, and spawning costs more on macOS.

 Checkout::inspect
   verify_repository                       # launch: rev-parse --git-common-dir
   registrations                           # worktree list --porcelain -z
-  rev-parse --verify HEAD
-  rev-parse --show-toplevel
-  rev-parse --absolute-git-dir
-  rev-parse --git-common-dir
+  Git::checkout_location                  # one rev-parse for all four
+    if output is not four lines (a path holds a newline)
+      read each value with its own rev-parse, as before
   rev-parse --symbolic-full-name HEAD
   for-each-ref refs/heads/<branch>
   verify_repository

The comparisons are unchanged. Each value is trimmed as Git::run trims.

Evidence

  • Before: spec_run a_ticket_needs_only_a_trusted_author_not_a_ready_label_of_its_own ran 5,415 programs (strace) in 19.6 s (12.3 s system time) on x86_64 Linux. One ordinary Worktree::head() ran 32 git processes.
    After: 4,221 programs (22% fewer) in ~17.2 s. One head() runs 23 git processes; an_ordinary_operation_inspects_ownership_in_few_git_processes fails at 32 and passes at 23.

  • The Spec review found a regression in the first commit: a newline in the path. Before the fix, a_checkout_path_with_a_newline_passes_ownership_inspection failed (test result: FAILED. 0 passed; 1 failed). It passes now. a_checkout_location_reads_a_linked_worktree_whatever_its_path checks paths with a newline and with a trailing space against the separate observations.

  • Full suite: cargo nextest run gives 2012 passed, 0 failed. cargo clippy --all-targets -- -D warnings and cargo fmt --check are clean.

  • macOS, test-step seconds per shard:

    Run Shards 1 / 2 / 3 / 4 Sum Slowest
    main 39337614995 1107 / 1120 / 969 / 1191 4387 1191
    main 39328254506 1193 / 937 / 1174 / 972 4276 1193
    this PR 39351810586 709 / 916 / 1089 / 905 3619 1089

    That is about 16% less macOS test time in total and about 9% off the slowest shard, from one run. Shard times vary by ±15% between runs.

Merge Danger

Door: two-way

A pure revert restores the four separate calls. Nothing is persisted.

Blast Radius: Worktree-ownership

Every Run's worktree inspection goes through Git::checkout_location. A wrong parse would refuse the Run's worktree operations (fail closed); it cannot authorize a different checkout, because every value is still compared with the pinned identity.

Unaddressed findings

Standards

Spec

Security review outcome

No unaddressed introduced findings.

Review coverage

The reviewers' reports cover commit b729ef0 and read every file it changed. The fixes in 2dcb944 came after the review. The changed file src/git/execution_tests.rs was left unread by both axes. Standards also did not read the new CheckoutLocation hunk in src/git.rs or the test appended to src/worktree/acquisition_tests.rs.

Closes #846

🤖 Generated with Claude Code

Built with claude · claude-opus-5-5 · medium

JacobStephens2 and others added 2 commits October 19, 2026 20:43
macOS CI spends its time running the suite, and the Run tests are bound
by spawning git, mostly for Worktree ownership inspection. One rev-parse
now reads the checkout's top level, administrative and common
directories and HEAD, so each inspection runs three fewer git processes
with the same checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Spec review found that splitting the combined rev-parse output into
four lines refused a checkout whose path holds a newline, which main
inspected successfully. Git::checkout_location now owns that parsing and
reads each value with its own process when the output is not four lines,
trimming each value as Git::run did, so the checks are those of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shorten macos CI time

1 participant