[ty] Speed up include filtering for projects with many literal include patterns by dhimasardinata · Pull Request #25266 · astral-sh/ruff (original) (raw)
MichaReiser changed the title
[ty] perf: speed up include literal matching [ty] Speed up include filtering for projects with many literal include patterns
thejchap pushed a commit to thejchap/ruff that referenced this pull request
…e patterns (astral-sh#25266)
Summary
- Track literal include globs in a bitset to avoid a linear scan over literal pattern indices.
- Keep the existing fast path when an include filter has no literal patterns.
- Add a ty benchmark that exercises a 1024-literal include set through
Project::is_file_included.
Benchmark
Command:
cargo bench -p ruff_benchmark --bench ty --no-default-features --features ty_instrumented ty_include_filter -- --sample-size 10
Results:
origin/mainwith this benchmark added:[1.4059 us 1.4082 us 1.4100 us]- This PR:
[957.18 ns 961.50 ns 965.61 ns]
This is about 1.46x faster, or a 31.7% reduction in time per literal include match in this benchmark.
Test Plan
cargo test -p ty_project glob::includecargo check -p ruff_benchmark --benches --no-default-features --features ty_instrumentedcargo bench -p ruff_benchmark --bench ty --no-default-features --features ty_instrumented ty_include_filter -- --sample-size 10
Refs astral-sh#25244
Co-authored-by: Micha Reiser micha@reiser.io
anishgirianish pushed a commit to anishgirianish/ruff that referenced this pull request
…e patterns (astral-sh#25266)
Summary
- Track literal include globs in a bitset to avoid a linear scan over literal pattern indices.
- Keep the existing fast path when an include filter has no literal patterns.
- Add a ty benchmark that exercises a 1024-literal include set through
Project::is_file_included.
Benchmark
Command:
cargo bench -p ruff_benchmark --bench ty --no-default-features --features ty_instrumented ty_include_filter -- --sample-size 10
Results:
origin/mainwith this benchmark added:[1.4059 us 1.4082 us 1.4100 us]- This PR:
[957.18 ns 961.50 ns 965.61 ns]
This is about 1.46x faster, or a 31.7% reduction in time per literal include match in this benchmark.
Test Plan
cargo test -p ty_project glob::includecargo check -p ruff_benchmark --benches --no-default-features --features ty_instrumentedcargo bench -p ruff_benchmark --bench ty --no-default-features --features ty_instrumented ty_include_filter -- --sample-size 10
Refs astral-sh#25244
Co-authored-by: Micha Reiser micha@reiser.io
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
[ Show hidden characters]({{ revealButtonHref }})