mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
163ee5e635
Replace use of strbuf_addf() with strbuf_add() when enumerating loose objects in for_each_file_in_obj_subdir(). Since we already check the length and hex-values of the string before consuming the path, we can prevent extra computation by using the lower- level method. One consumer of for_each_file_in_obj_subdir() is the abbreviation code. OID abbreviations use a cached list of loose objects (per object subdirectory) to make repeated queries fast, but there is significant cache load time when there are many loose objects. Most repositories do not have many loose objects before repacking, but in the GVFS case the repos can grow to have millions of loose objects. Profiling 'git log' performance in GitForWindows on a GVFS-enabled repo with ~2.5 million loose objects revealed 12% of the CPU time was spent in strbuf_addf(). Add a new performance test to p4211-line-log.sh that is more sensitive to this cache-loading. By limiting to 1000 commits, we more closely resemble user wait time when reading history into a pager. For a copy of the Linux repo with two ~512 MB packfiles and ~572K loose objects, running 'git log --oneline --parents --raw -1000' had the following performance: HEAD~1 HEAD ---------------------------------------- 7.70(7.15+0.54) 7.44(7.09+0.29) -3.4% Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
42 lines
917 B
Bash
Executable file
42 lines
917 B
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='Tests log -L performance'
|
|
. ./perf-lib.sh
|
|
|
|
test_perf_default_repo
|
|
|
|
# Pick a file to log pseudo-randomly. The sort key is the blob hash,
|
|
# so it is stable.
|
|
test_expect_success 'select a file' '
|
|
git ls-tree HEAD | grep ^100644 |
|
|
sort -k 3 | head -1 | cut -f 2 >filelist
|
|
'
|
|
|
|
file=$(cat filelist)
|
|
export file
|
|
|
|
test_perf 'git rev-list --topo-order (baseline)' '
|
|
git rev-list --topo-order HEAD >/dev/null
|
|
'
|
|
|
|
test_perf 'git log --follow (baseline for -M)' '
|
|
git log --oneline --follow -- "$file" >/dev/null
|
|
'
|
|
|
|
test_perf 'git log -L (renames off)' '
|
|
git log --no-renames -L 1:"$file" >/dev/null
|
|
'
|
|
|
|
test_perf 'git log -L (renames on)' '
|
|
git log -M -L 1:"$file" >/dev/null
|
|
'
|
|
|
|
test_perf 'git log --oneline --raw --parents' '
|
|
git log --oneline --raw --parents >/dev/null
|
|
'
|
|
|
|
test_perf 'git log --oneline --raw --parents -1000' '
|
|
git log --oneline --raw --parents -1000 >/dev/null
|
|
'
|
|
|
|
test_done
|