-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Matchit to Resolve Per-File Settings (#11111)
## Summary Continuation of #9444. > When the formatter is fully cached, it turns out we actually spend meaningful time mapping from file to `Settings` (since we use a hierarchical approach to settings). Using `matchit` rather than `BTreeMap` improves fully-cached performance by anywhere from 2-5% depending on the project, and since these are all implementation details of `Resolver`, it's minimally invasive. `matchit` supports escaping routing characters so this change should now be fully compatible. ## Test Plan On my machine I'm seeing a ~3% improvement with this change. ``` hyperfine --warmup 20 -i "./target/release/main format ../airflow" "./target/release/ruff format ../airflow" Benchmark 1: ./target/release/main format ../airflow Time (mean ± σ): 58.1 ms ± 1.4 ms [User: 63.1 ms, System: 66.5 ms] Range (min … max): 56.1 ms … 62.9 ms 49 runs Benchmark 2: ./target/release/ruff format ../airflow Time (mean ± σ): 56.6 ms ± 1.5 ms [User: 57.8 ms, System: 67.7 ms] Range (min … max): 54.1 ms … 63.0 ms 51 runs Summary ./target/release/ruff format ../airflow ran 1.03 ± 0.04 times faster than ./target/release/main format ../airflow ```
- Loading branch information
1 parent
37af6e6
commit 1c8849f
Showing
4 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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