diff options
author | René Scharfe <l.s.r@web.de> | 2020-02-05 18:50:23 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-02-05 10:36:33 -0800 |
commit | 079f970971e8e66bdf5b67d924fc2a5177277ffd (patch) | |
tree | 21c7665cfa349993ca6b66848948c089dc0ad384 /Documentation/git-name-rev.txt | |
parent | name-rev: release unused name strings (diff) | |
download | tgif-079f970971e8e66bdf5b67d924fc2a5177277ffd.tar.xz |
name-rev: sort tip names before applying
name_ref() is called for each ref and checks if its a better name for
the referenced commit. If that's the case it remembers it and checks if
a name based on it is better for its ancestors as well. This in done in
the the order for_each_ref() imposes on us.
That might not be optimal. If bad names happen to be encountered first
(as defined by is_better_name()), names derived from them may spread to
a lot of commits, only to be replaced by better names later. Setting
better names first can avoid that.
is_better_name() prefers tags, short distances and old references. The
distance is a measure that we need to calculate for each candidate
commit, but the other two properties are not dependent on the
relationships of commits. Sorting the refs by them should yield better
performance than the essentially random order we currently use.
And applying older references first should also help to reduce rework
due to the fact that older commits have less ancestors than newer ones.
So add all details of names to the tip table first, then sort them
to prefer tags and older references and then apply them in this order.
Here's the performance as measures by hyperfine for the Linux repo
before:
Benchmark #1: ./git -C ../linux/ name-rev --all
Time (mean ± σ): 851.1 ms ± 4.5 ms [User: 806.7 ms, System: 44.4 ms]
Range (min … max): 845.9 ms … 859.5 ms 10 runs
... and with this patch:
Benchmark #1: ./git -C ../linux/ name-rev --all
Time (mean ± σ): 736.2 ms ± 8.7 ms [User: 688.4 ms, System: 47.5 ms]
Range (min … max): 726.0 ms … 755.2 ms 10 runs
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-name-rev.txt')
0 files changed, 0 insertions, 0 deletions