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: spawn snapshot job per directory
This change basically means two things: a. a directory scan isn't split into too many small jobs, and b. a directory scan isn't blocked by recursive visit_directory() calls. Before, small jobs were created at each recursion depth, so there were silent time slice before these jobs started producing work. I don't know if this mitigates the issue #4508, but it's slightly faster on my Linux machine (except for the "git" repo which doesn't have many directories to parallelize jobs.) The implementation is also simpler. matcher.visit(dir) is moved to caller because it's silly to spawn an empty job. TreeState::snapshot() already checks that for the root path. This change will allow us to build a set of deleted files per directory, which will reduce the overhead to send "present" files over the channel. Benchmark: - jj-0: original - jj-1: this patch gecko-dev (large): ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 10 -L bin jj-0,jj-1,jj-2 \ 'target/release-with-debug/{bin} -R ~/mirrors/gecko-dev debug snapshot' Benchmark 1: target/release-with-debug/jj-0 -R ~/mirrors/gecko-dev debug snapshot Time (mean ± σ): 707.4 ms ± 12.3 ms [User: 2880.2 ms, System: 1939.1 ms] Range (min … max): 684.4 ms … 721.7 ms 10 runs Benchmark 2: target/release-with-debug/jj-1 -R ~/mirrors/gecko-dev debug snapshot Time (mean ± σ): 659.6 ms ± 11.8 ms [User: 2673.2 ms, System: 1882.1 ms] Range (min … max): 649.2 ms … 690.1 ms 10 runs Relative speed comparison 1.61 ± 0.05 target/release-with-debug/jj-0 -R ~/mirrors/gecko-dev debug snapshot 1.50 ± 0.05 target/release-with-debug/jj-1 -R ~/mirrors/gecko-dev debug snapshot ``` linux (mid-size): ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 10 -L bin jj-0,jj-1,jj-2 \ 'target/release-with-debug/{bin} -R ~/mirrors/linux debug snapshot' Benchmark 1: target/release-with-debug/jj-0 -R ~/mirrors/linux debug snapshot Time (mean ± σ): 256.3 ms ± 6.2 ms [User: 573.0 ms, System: 459.2 ms] Range (min … max): 248.5 ms … 266.0 ms 10 runs Benchmark 2: target/release-with-debug/jj-1 -R ~/mirrors/linux debug snapshot Time (mean ± σ): 225.5 ms ± 4.2 ms [User: 563.3 ms, System: 475.8 ms] Range (min … max): 218.7 ms … 231.4 ms 10 runs Relative speed comparison 1.35 ± 0.04 target/release-with-debug/jj-0 -R ~/mirrors/linux debug snapshot 1.19 ± 0.03 target/release-with-debug/jj-1 -R ~/mirrors/linux debug snapshot ``` git (small, flat): ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 100 -L bin jj-0,jj-1,jj-2 \ 'target/release-with-debug/{bin} -R ~/mirrors/git debug snapshot' Benchmark 1: target/release-with-debug/jj-0 -R ~/mirrors/git debug snapshot Time (mean ± σ): 30.6 ms ± 1.6 ms [User: 38.8 ms, System: 40.6 ms] Range (min … max): 28.1 ms … 43.8 ms 100 runs Benchmark 2: target/release-with-debug/jj-1 -R ~/mirrors/git debug snapshot Time (mean ± σ): 34.0 ms ± 1.2 ms [User: 33.5 ms, System: 47.5 ms] Range (min … max): 31.5 ms … 39.2 ms 100 runs Relative speed comparison 1.00 target/release-with-debug/jj-0 -R ~/mirrors/git debug snapshot 1.11 ± 0.07 target/release-with-debug/jj-1 -R ~/mirrors/git debug snapshot ``` jj (small, structured): ``` % JJ_CONFIG=/dev/null hyperfine --sort command --warmup 3 --runs 100 -L bin jj-0,jj-1,jj-2 \ 'target/release-with-debug/{bin} -R . debug snapshot' Benchmark 1: target/release-with-debug/jj-0 -R . debug snapshot Time (mean ± σ): 30.9 ms ± 1.6 ms [User: 16.3 ms, System: 28.0 ms] Range (min … max): 28.9 ms … 41.8 ms 100 runs Benchmark 2: target/release-with-debug/jj-1 -R . debug snapshot Time (mean ± σ): 31.2 ms ± 1.9 ms [User: 15.3 ms, System: 27.0 ms] Range (min … max): 29.0 ms … 43.3 ms 100 runs Relative speed comparison 1.00 target/release-with-debug/jj-0 -R . debug snapshot 1.01 ± 0.08 target/release-with-debug/jj-1 -R . debug snapshot ``` - CPU: 8-core AMD Ryzen 7 PRO 4750U with Radeon Graphics (-MT MCP-) - speed/min/max: 1600/1400/1700 MHz Kernel: 6.11.10-amd64 x86_64 - Filesystem: ext4
- Loading branch information