diff options
author | Jeff King <peff@peff.net> | 2013-07-02 02:16:23 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-02 12:03:34 -0700 |
commit | 16445242edd7e90dc564b657043d2a5efca68cb0 (patch) | |
tree | 09c8c2ffe659d4c0776891fb2938b48f6982160d /Documentation/RelNotes/1.7.8.txt | |
parent | Merge branch 'jc/topo-author-date-sort' (diff) | |
download | tgif-16445242edd7e90dc564b657043d2a5efca68cb0.tar.xz |
fetch-pack: avoid quadratic list insertion in mark_complete
We insert the commit pointed to by each ref one-by-one into
the "complete" commit_list using insert_by_date. Because
each insertion is O(n), we end up with O(n^2) behavior.
This typically doesn't matter, because the number of refs is
reasonably small. And even if there are a lot of refs, they
often point to a smaller set of objects (in which case the
optimization in commit ea5f220 keeps our "n" small).
However, in pathological repositories (hundreds of thousands
of refs, each pointing to a unique commit), this quadratic
behavior can make a difference. Since we do not care about
the list order until we have finished building it, we can
simply keep it unsorted during the insertion phase, then
sort it afterwards.
On a repository like the one described above, this dropped
the time to do a no-op fetch from 2.0s to 1.7s. On normal
repositories, it probably does not matter at all, but it
does not hurt to protect ourselves from pathological cases.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/RelNotes/1.7.8.txt')
0 files changed, 0 insertions, 0 deletions