Repository navigation
perf: match .gitignore without contention between walk threads - #1523
Merged
Merged
Conversation
Gitignore::matched borrows a match buffer from a pool only its owner thread reaches lock-free; the walk's other threads contended on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1481
./**in a git repo: each walk thread now matches a.gitignorethrough its own compiled copy.Gitignore::matchedborrows its match buffer from a pool. Only the pool's first caller gets it without a lock; the walk's other threads contend on the rest. In a microbenchmark of 1.6M paths, matching on 32 threads took 30.7ms through one sharedGitignoreand 7.7ms through one copy per thread.Frame(gitignore_frame.rs) wraps theGitignoreand keeps a lazily built copy per thread slot, compiled from the same file by the sameGitignoreBuildercalls. Matching semantics stay with theignorecrate. If a copy no longer compiles, matching falls back to the sharedGitignore.Measured on a 3.2M-item corpus built by
glob_speed_gitignore_test.build_tree(1.84M visible files), hyperfine, 40 runs, host load ~17, 32 cores. Medians:SELECT count(*) FROM './**'(walk only)SELECT path FROM './**'The walk uses 13% less CPU. The wall-clock gain is small on an idle 32-core host and larger under load.
This PR alone does not close #1481. Most of the gap is in the output path, which PR #1513 fixes. In
glob_speed_gitignore_test:Once #1513 merges, the test's bar can be pinned to
FASTEST.Changelog / Migrations
packages/rust/changelog.d/for each changed packagepackages/rust/migrations.d/for each changed package (every subsection but Summary_None._)E2E Verification
cargo test --workspace --features cli)packages/python/e2e-attestations/<branch>.jsonreceipt writtenpackages/ts/e2e-attestations/<branch>.jsonreceipt writtentesting-conventions e2e attest 'uv run python -m pytest tests/e2e/glob_speed_gitignore_test.py tests/e2e/glob_speed_matchers_test.py tests/e2e/glob_speed_recursive_test.py tests/e2e/query_contract_test.py -x -q -s'(inpackages/python, aftermaturin develop --releaseandcargo build --release -p dirsql --features cli),testing-conventions e2e attest 'pnpm test:e2e'(inpackages/ts),cargo test --workspace --features cliSELECT path FROM './**'output is byte-identical to main (md5 over 1.84M rows).