Skip to content

perf: Pre-compile glob exclusion filter and cache path prefix in file hashing#11891

Merged
anthonyshew merged 1 commit intomainfrom
shew/make-stuff-faster
Feb 17, 2026
Merged

perf: Pre-compile glob exclusion filter and cache path prefix in file hashing#11891
anthonyshew merged 1 commit intomainfrom
shew/make-stuff-faster

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

Summary

  • Pre-compile glob exclusion patterns once in globwalk_internal instead of cloning Vec<Glob> per include pattern and re-compiling each time. Adds FileIterator::not_any to wax to accept a pre-compiled FilterAny directly.
  • Cache the git-root-to-package path prefix in hash_objects so each file does a cheap strip_prefix instead of full relative_path_between path component iteration.

Why

CPU profiling showed get_package_file_hashes as the dominant hotspot (538% self time). Within that path, globwalk_internal was cloning and re-compiling exclusion Glob patterns (each containing a compiled Regex) for every include glob — O(N includes × M excludes) regex clones + N recompilations per globwalk call. In hash_objects, the path prefix computation was doing redundant component iteration for every file when the relationship between git root and package path is constant.

Benchmarks

Measured with hyperfine --warmup 5 across three monorepos of different sizes:

~300 packages:

Benchmark 1 (patched):  6.584s ± 0.144s
Benchmark 2 (baseline): 7.087s ± 0.141s
  → 1.08 ± 0.03 times faster

~100 packages:

Benchmark 1 (patched):  1.378s ± 0.104s
Benchmark 2 (baseline): 1.414s ± 0.059s
  → 1.03 ± 0.09 times faster

~6 packages:

Benchmark 1 (patched):  643.8ms ± 65.1ms
Benchmark 2 (baseline): 671.1ms ± 99.8ms
  → 1.04 ± 0.19 (within noise)

Improvements scale with package count as expected since both optimizations eliminate per-package redundant work.

Testing

All existing tests pass across wax, globwalk, turborepo-scm, and turborepo-task-hash.

@anthonyshew anthonyshew requested a review from a team as a code owner February 17, 2026 23:01
@anthonyshew anthonyshew requested review from tknickman and removed request for a team February 17, 2026 23:01
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 17, 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 17, 2026 11:11pm
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
turbo-site Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm
turborepo-test-coverage Ready Ready Preview, Comment, Open in v0 Feb 17, 2026 11:11pm

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Metric Coverage
Lines 76.42%
Functions 47.26%
Branches 0.00%

View full report

@anthonyshew anthonyshew merged commit 2af1c0d into main Feb 17, 2026
102 checks passed
@anthonyshew anthonyshew deleted the shew/make-stuff-faster branch February 17, 2026 23:25
github-actions Bot added a commit that referenced this pull request Feb 18, 2026
## Release v2.8.10-canary.9

Versioned docs: https://v2-8-10-canary-9.turborepo.dev

### Changes

- release(turborepo): 2.8.10-canary.8 (#11890) (`31e29c9`)
- perf: Pre-compile glob exclusion filter and cache path prefix in file
hashing (#11891) (`2af1c0d`)

---------

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