summaryrefslogtreecommitdiff
path: root/column.h
diff options
context:
space:
mode:
authorLibravatar Derrick Stolee <dstolee@microsoft.com>2021-01-07 16:32:11 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-01-15 23:05:13 -0800
commita4b6d202caad83c6dc29abe9b17e53a1b3fb54a0 (patch)
treedc54967dc8af006c050712f4071b72e9c05bce39 /column.h
parentcache-tree: use ce_namelen() instead of strlen() (diff)
downloadtgif-a4b6d202caad83c6dc29abe9b17e53a1b3fb54a0.tar.xz
cache-tree: speed up consecutive path comparisons
The previous change reduced time spent in strlen() while comparing consecutive paths in verify_cache(), but we can do better. The conditional checks the existence of a directory separator at the correct location, but only after doing a string comparison. Swap the order to be logically equivalent but perform fewer string comparisons. To test the effect on performance, I used a repository with over three million paths in the index. I then ran the following command on repeat: git -c index.threads=1 commit --amend --allow-empty --no-edit Here are the measurements over 10 runs after a 5-run warmup: Benchmark #1: v2.30.0 Time (mean ± σ): 854.5 ms ± 18.2 ms Range (min … max): 825.0 ms … 892.8 ms Benchmark #2: Previous change Time (mean ± σ): 833.2 ms ± 10.3 ms Range (min … max): 815.8 ms … 849.7 ms Benchmark #3: This change Time (mean ± σ): 815.5 ms ± 18.1 ms Range (min … max): 795.4 ms … 849.5 ms This change is 2% faster than the previous change and 5% faster than v2.30.0. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'column.h')
0 files changed, 0 insertions, 0 deletions