Build and reuse a run-scoped file index#2361
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2361 +/- ##
==========================================
- Coverage 93.36% 93.33% -0.03%
==========================================
Files 129 129
Lines 27408 27427 +19
==========================================
+ Hits 25589 25600 +11
- Misses 1819 1827 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.00% (29.1 MiB → 29.1 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
⚡️ Hyperfine BenchmarksSummary: 0 regressions, 1 improvements above the 10% threshold. Environment
CLI CommandsBenchmarking basic commands in the main repo:
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base --version |
2.2 ± 0.1 | 2.1 | 2.5 | 1.05 ± 0.05 |
prek-head --version |
2.1 ± 0.1 | 2.0 | 2.4 | 1.00 |
prek list
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base list |
9.2 ± 0.9 | 8.9 | 17.5 | 1.02 ± 0.10 |
prek-head list |
9.1 ± 0.1 | 8.9 | 9.5 | 1.00 |
prek validate-config .pre-commit-config.yaml
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base validate-config .pre-commit-config.yaml |
3.1 ± 0.1 | 3.0 | 3.4 | 1.02 ± 0.04 |
prek-head validate-config .pre-commit-config.yaml |
3.1 ± 0.1 | 3.0 | 3.2 | 1.00 |
prek sample-config
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base sample-config |
2.4 ± 0.0 | 2.3 | 2.5 | 1.01 ± 0.03 |
prek-head sample-config |
2.4 ± 0.1 | 2.3 | 2.5 | 1.00 |
Cold vs Warm Runs
Comparing first run (cold) vs subsequent runs (warm cache):
prek run --all-files (cold - no cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
75.3 ± 2.4 | 72.1 | 79.0 | 1.00 |
prek-head run --all-files |
75.9 ± 2.6 | 70.5 | 79.0 | 1.01 ± 0.05 |
prek run --all-files (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
76.1 ± 7.6 | 70.8 | 107.1 | 1.03 ± 0.11 |
prek-head run --all-files |
74.2 ± 2.3 | 69.5 | 77.1 | 1.00 |
Full Hook Suite
Running the builtin hook suite on the benchmark workspace:
prek run --all-files (full builtin hook suite)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
74.4 ± 2.6 | 70.2 | 81.6 | 1.00 |
prek-head run --all-files |
75.6 ± 2.6 | 70.4 | 80.8 | 1.02 ± 0.05 |
Individual Hook Performance
Benchmarking each hook individually on the test repo:
prek run trailing-whitespace --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run trailing-whitespace --all-files |
19.6 ± 0.3 | 19.0 | 20.4 | 1.00 |
prek-head run trailing-whitespace --all-files |
19.7 ± 0.3 | 19.2 | 20.3 | 1.00 ± 0.02 |
prek run end-of-file-fixer --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run end-of-file-fixer --all-files |
25.8 ± 2.3 | 23.1 | 31.7 | 1.01 ± 0.12 |
prek-head run end-of-file-fixer --all-files |
25.4 ± 2.0 | 23.0 | 29.6 | 1.00 |
prek run check-json --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-json --all-files |
7.5 ± 0.2 | 7.0 | 7.9 | 1.01 ± 0.04 |
prek-head run check-json --all-files |
7.4 ± 0.2 | 7.1 | 7.9 | 1.00 |
prek run check-yaml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-yaml --all-files |
7.3 ± 0.1 | 7.1 | 7.5 | 1.00 ± 0.02 |
prek-head run check-yaml --all-files |
7.3 ± 0.1 | 7.1 | 7.6 | 1.00 |
prek run check-toml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-toml --all-files |
7.4 ± 0.3 | 7.0 | 8.1 | 1.01 ± 0.05 |
prek-head run check-toml --all-files |
7.4 ± 0.3 | 7.0 | 8.0 | 1.00 |
prek run check-xml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-xml --all-files |
7.3 ± 0.4 | 6.9 | 8.3 | 1.00 |
prek-head run check-xml --all-files |
7.4 ± 0.4 | 7.0 | 8.5 | 1.01 ± 0.08 |
prek run detect-private-key --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run detect-private-key --all-files |
13.6 ± 1.3 | 11.9 | 16.8 | 1.00 |
prek-head run detect-private-key --all-files |
13.7 ± 1.6 | 11.9 | 18.7 | 1.01 ± 0.15 |
prek run fix-byte-order-marker --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run fix-byte-order-marker --all-files |
18.5 ± 2.6 | 16.8 | 28.4 | 1.02 ± 0.15 |
prek-head run fix-byte-order-marker --all-files |
18.2 ± 0.7 | 17.2 | 19.6 | 1.00 |
Installation Performance
Benchmarking hook installation (fast path hooks skip Python setup):
prek install-hooks (cold - no cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
4.4 ± 0.1 | 4.3 | 4.5 | 1.00 |
prek-head install-hooks |
4.5 ± 0.0 | 4.4 | 4.5 | 1.02 ± 0.02 |
prek install-hooks (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
4.5 ± 0.1 | 4.5 | 4.6 | 1.02 ± 0.03 |
prek-head install-hooks |
4.4 ± 0.1 | 4.3 | 4.6 | 1.00 |
File Filtering/Scoping Performance
Testing different file selection modes:
prek run (staged files only)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run |
37.3 ± 1.0 | 36.1 | 40.7 | 1.00 ± 0.04 |
prek-head run |
37.2 ± 0.9 | 36.3 | 39.4 | 1.00 |
prek run --files '*.json' (specific file type)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --files '*.json' |
7.8 ± 0.1 | 7.7 | 8.1 | 1.01 ± 0.02 |
prek-head run --files '*.json' |
7.7 ± 0.1 | 7.6 | 7.9 | 1.00 |
Workspace Discovery & Initialization
Benchmarking hook discovery and initialization overhead:
prek run --dry-run --all-files (measures init overhead)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --dry-run --all-files |
6.6 ± 0.1 | 6.5 | 7.0 | 1.01 ± 0.02 |
prek-head run --dry-run --all-files |
6.6 ± 0.1 | 6.4 | 6.7 | 1.00 |
Meta Hooks Performance
Benchmarking meta hooks separately:
prek run check-hooks-apply --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-hooks-apply --all-files |
11.5 ± 0.2 | 11.4 | 12.2 | 1.12 ± 0.02 |
prek-head run check-hooks-apply --all-files |
10.3 ± 0.1 | 10.2 | 10.6 | 1.00 |
✅ Performance improvement for prek run check-hooks-apply --all-files: 10.5500% faster
prek run check-useless-excludes --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-useless-excludes --all-files |
10.4 ± 0.1 | 10.3 | 10.6 | 1.00 |
prek-head run check-useless-excludes --all-files |
10.5 ± 0.7 | 10.2 | 13.0 | 1.01 ± 0.07 |
prek run identity --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run identity --all-files |
9.9 ± 0.8 | 9.5 | 12.3 | 1.03 ± 0.08 |
prek-head run identity --all-files |
9.5 ± 0.1 | 9.4 | 9.7 | 1.00 |
Build a run-scoped file index once and reuse per-project file views during hook installation and execution, avoiding repeated project × file scans.
Benchmark
profilingprofile, 1,000 projects / 101,001 tracked files,prek run --all-files --dry-run, 2 warmups and 10 runs:14.04 ± 0.24× faster (92.88% less time). Average maximum RSS increased from 36.58 MiB to 38.91 MiB (+2.33 MiB).
The baseline
ProjectFiles::for_projecthotspot (38.56% of samples) disappears from the optimized flamegraph.