Skip to content

perf(monorepo): reuse the tag index ancestor set instead of walking twice#683

Merged
BryanFRD merged 1 commit into
mainfrom
perf/reuse-tag-index-ancestors
Jul 15, 2026
Merged

perf(monorepo): reuse the tag index ancestor set instead of walking twice#683
BryanFRD merged 1 commit into
mainfrom
perf/reuse-tag-index-ancestors

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

run_release_logic walked HEAD's full ancestry twice, and threw the first walk away.

build_head_ancestors (mod.rs:150) and TagIndex::build run the byte-identical revwalk, and TagIndex already exposes the result as pub ancestors. On top of that, all four reads of inputs.head_ancestors (plan.rs:128/160/183/197) live in the else of if let (Some(idx), OrphanedTagStrategy::Warn) = (inputs.tag_index, strategy) — and Warn is #[default] while TagIndex::build normally succeeds. So in the default configuration the first walk was dead work: nothing read it.

src/query.rs:229 already does Some(&idx.ancestors); this path simply missed the same reuse.

Now the index is built first and its ancestor set is passed through; the standalone walk only runs as a fallback when the index is unavailable (which is also the only case where the else branches can fire).

Measured — A/B on the real CI fixture

mono-large (200 packages × 10k commits), generated from benchmarks/fixtures/definitions/mono-large.json with the Fixtures generator and the same ferrflow.json the benchmark harness writes. check --jobs 1, cache cleared before every run, same binary/machine, n=3:

run 1 run 2 run 3 median
before 2722 ms 2568 ms 2551 ms 2568 ms
after 2069 ms 2078 ms 2137 ms 2078 ms

−490 ms, −19%.

This is not a benchmark-only win. The cache key is head + tags_hash + config_hash (cache.rs:42-56), so every push invalidates it — a one-run-per-push CI job is always cold. Cold numbers are the real numbers.

875 tests pass, clippy -D warnings clean. No observable behaviour change: the ancestor set is identical, only its provenance changes.

Closes #682

@BryanFRD BryanFRD enabled auto-merge (squash) July 15, 2026 20:35
@BryanFRD BryanFRD merged commit f77bd6e into main Jul 15, 2026
39 checks passed
@BryanFRD BryanFRD deleted the perf/reuse-tag-index-ancestors branch July 15, 2026 20:37
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.

Monorepo run walks HEAD's ancestry twice, and the first walk is never read

1 participant