Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
local_working_copy: optimize path comparison in prefixed file states
Since all entries in filtered file states share the same directory prefix, we don't need to compare full file paths. The added functions take (path, name) instead of (path, sub_path) because the comparison can be slightly faster if the name is guaranteed to be a single path component. Benchmark: 1. original (omitted) 2. per-directory spawn (omitted) 3. per-directory deleted files (previous patch) 4. shorter path comparison (this patch) gecko-dev (~357k files, ~25k dirs) ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 30 .. Benchmark 3: target/release-with-debug/jj-3 -R ~/mirrors/gecko-dev debug snapshot Time (mean ± σ): 480.1 ms ± 8.8 ms [User: 3190.5 ms, System: 2127.2 ms] Range (min … max): 471.2 ms … 509.8 ms 30 runs Benchmark 4: target/release-with-debug/jj-4 -R ~/mirrors/gecko-dev debug snapshot Time (mean ± σ): 404.0 ms ± 4.4 ms [User: 1933.4 ms, System: 2148.8 ms] Range (min … max): 396.4 ms … 416.9 ms 30 runs Relative speed comparison 1.19 ± 0.03 target/release-with-debug/jj-3 -R ~/mirrors/gecko-dev debug snapshot 1.00 target/release-with-debug/jj-4 -R ~/mirrors/gecko-dev debug snapshot ``` linux (~87k files, ~6k dirs) ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 30 .. Benchmark 3: target/release-with-debug/jj-3 -R ~/mirrors/linux debug snapshot Time (mean ± σ): 204.2 ms ± 3.0 ms [User: 667.3 ms, System: 545.6 ms] Range (min … max): 197.1 ms … 209.2 ms 30 runs Benchmark 4: target/release-with-debug/jj-4 -R ~/mirrors/linux debug snapshot Time (mean ± σ): 191.3 ms ± 3.3 ms [User: 467.4 ms, System: 542.2 ms] Range (min … max): 186.1 ms … 200.6 ms 30 runs Relative speed comparison 1.07 ± 0.02 target/release-with-debug/jj-3 -R ~/mirrors/linux debug snapshot 1.00 target/release-with-debug/jj-4 -R ~/mirrors/linux debug snapshot ``` nixpkgs (~45k files, ~31k dirs) ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 30 .. Benchmark 3: target/release-with-debug/jj-3 -R ~/mirrors/nixpkgs debug snapshot Time (mean ± σ): 173.3 ms ± 6.7 ms [User: 899.4 ms, System: 889.0 ms] Range (min … max): 166.5 ms … 197.9 ms 30 runs Benchmark 4: target/release-with-debug/jj-4 -R ~/mirrors/nixpkgs debug snapshot Time (mean ± σ): 161.7 ms ± 2.5 ms [User: 739.1 ms, System: 881.7 ms] Range (min … max): 156.5 ms … 166.4 ms 30 runs Relative speed comparison 1.07 ± 0.04 target/release-with-debug/jj-3 -R ~/mirrors/nixpkgs debug snapshot 1.00 target/release-with-debug/jj-4 -R ~/mirrors/nixpkgs debug snapshot ``` git (~4.5k files, 0.2k dirs) ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 30 --runs 50 .. Benchmark 3: target/release-with-debug/jj-3 -R ~/mirrors/git debug snapshot Time (mean ± σ): 28.8 ms ± 1.0 ms [User: 33.0 ms, System: 37.6 ms] Range (min … max): 26.8 ms … 31.3 ms 50 runs Benchmark 4: target/release-with-debug/jj-4 -R ~/mirrors/git debug snapshot Time (mean ± σ): 28.8 ms ± 1.9 ms [User: 30.3 ms, System: 36.5 ms] Range (min … max): 26.0 ms … 39.2 ms 50 runs Relative speed comparison 1.00 target/release-with-debug/jj-3 -R ~/mirrors/git debug snapshot 1.00 ± 0.08 target/release-with-debug/jj-4 -R ~/mirrors/git debug snapshot ```
- Loading branch information