Skip to content

Comments

perf: Reduce per-package hashing overhead and eliminate SCM subprocesses#11942

Merged
anthonyshew merged 2 commits intomainfrom
faster-and-faster-2
Feb 20, 2026
Merged

perf: Reduce per-package hashing overhead and eliminate SCM subprocesses#11942
anthonyshew merged 2 commits intomainfrom
faster-and-faster-2

Conversation

@anthonyshew
Copy link
Contributor

@anthonyshew anthonyshew commented Feb 20, 2026

Summary

Follow-up to #11938. Targets the per-package hashing hot path that dominates at scale, plus eliminates the last two git subprocesses from --dry runs.

Small repo (~6 packages)

Mean Range
This PR 571.2ms ± 46.7ms 515.6ms - 651.7ms
main 587.4ms ± 45.1ms 524.9ms - 676.3ms
1.03 ± 0.12x faster

Medium repo (~120 packages)

Mean Range
This PR 1.096s ± 0.095s 1.015s - 1.280s
main 1.119s ± 0.072s 1.042s - 1.259s
1.02 ± 0.11x faster

Large repo (~1000 packages)

Mean Range
This PR 1.729s ± 0.151s 1.548s - 1.969s
main 1.833s ± 0.181s 1.583s - 2.099s
1.06 ± 0.14x faster

The small repo results best isolate the fixed-cost improvements (git2 for branch/SHA, reduced allocation overhead) since per-package work is minimal. At larger scales, the improvements are present but within noise because wall-clock time is already well-parallelized across rayon threads.

Benchmarks

All benchmarks: turbo run <task> --skip-infer --dry, 5 warmup + 10 measured runs, release build.

Changes

  • FileHashes: HashMap to sorted VecFileHashes inner type changed from HashMap to pre-sorted Vec. Eliminates HashMap construction (hashing, bucket allocation, rehashing) in the per-package hashing pipeline and removes redundant re-sorting in Cap'n Proto serialization. The sort happens once at the construction boundary; downstream consumers (expanded_inputs, .hash()) get pre-sorted data for free.

  • Status entry binary searchget_package_hashes now uses partition_point on pre-sorted status entries instead of a linear scan. Reduces per-package status lookup from O(dirty_files) to O(log(dirty_files) + matched). Also adds with_capacity to the per-package HashMap to avoid rehashing.

  • git2 for branch/SHAget_current_branch and get_current_sha (called by SCMState::get in to_summary) now use git2::Repository instead of forking git branch --show-current and git rev-parse HEAD. Gated behind #[cfg(feature = "git2")] with subprocess fallback.

@anthonyshew anthonyshew requested a review from a team as a code owner February 20, 2026 21:54
@anthonyshew anthonyshew requested review from tknickman and removed request for a team February 20, 2026 21:54
@vercel
Copy link
Contributor

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
turbo-site Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm
turborepo-test-coverage Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:02pm

@github-actions
Copy link
Contributor

Coverage Report

Metric Coverage
Lines 75.13%
Functions 46.72%
Branches 0.00%

View full report

@anthonyshew
Copy link
Contributor Author

The tests that are failing are flakes. Merging past.

@anthonyshew anthonyshew merged commit fc19b66 into main Feb 20, 2026
98 of 101 checks passed
@anthonyshew anthonyshew deleted the faster-and-faster-2 branch February 20, 2026 22:26
github-actions bot added a commit that referenced this pull request Feb 20, 2026
## Release v2.8.11-canary.16

Versioned docs: https://v2-8-11-canary-16.turborepo.dev

### Changes

- release(turborepo): 2.8.11-canary.15 (#11943) (`ef6dfd2`)
- perf: Reduce per-package hashing overhead and eliminate SCM
subprocesses (#11942) (`fc19b66`)

---------

Co-authored-by: Turbobot <turbobot@vercel.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.

1 participant