Files
git/builtin
Jeff King cd37996795 pack-objects: break out of want_object loop early
When pack-objects collects the list of objects to pack
(either from stdin, or via its internal rev-list), it
filters each one through want_object_in_pack().

This function loops through each existing packfile, looking
for the object. When we find it, we mark the pack/offset
combo for later use. However, we can't just return "yes, we
want it" at that point. If --honor-pack-keep is in effect,
we must keep looking to find it in _all_ packs, to make sure
none of them has a .keep. Likewise, if --local is in effect,
we must make sure it is not present in any non-local pack.

As a result, the sum effort of these calls is effectively
O(nr_objects * nr_packs). In an ordinary repository, we have
only a handful of packs, and this doesn't make a big
difference. But in pathological cases, it can slow the
counting phase to a crawl.

This patch notices the case that we have neither "--local"
nor "--honor-pack-keep" in effect and breaks out of the loop
early, after finding the first instance. Note that our worst
case is still "objects * packs" (i.e., we might find each
object in the last pack we look in), but in practice we will
often break out early. On an "average" repo, my git.git with
8 packs, this shows a modest 2% (a few dozen milliseconds)
improvement in the counting-objects phase of "git
pack-objects --all <foo" (hackily instrumented by sticking
exit(0) right after list_objects).

But in a much more pathological case, it makes a bigger
difference. I ran the same command on a real-world example
with ~9 million objects across 1300 packs. The counting time
dropped from 413s to 45s, an improvement of about 89%.

Note that this patch won't do anything by itself for a
normal "git gc", as it uses both --honor-pack-keep and
--local.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-07-29 11:05:07 -07:00
..
2016-06-07 17:43:39 -07:00
2016-07-13 11:24:10 -07:00
2016-07-19 13:22:16 -07:00
2016-07-19 13:22:23 -07:00
2016-07-13 11:24:10 -07:00
2016-02-26 13:37:16 -08:00
2016-07-19 13:22:21 -07:00
2016-07-13 11:24:12 -07:00
2016-07-13 11:24:18 -07:00
2016-05-09 12:29:08 -07:00
2016-06-17 15:46:10 -07:00
2016-07-19 13:22:15 -07:00
2016-02-10 14:20:08 -08:00
2016-07-19 13:22:23 -07:00
2016-02-26 13:37:16 -08:00
2016-07-13 11:24:10 -07:00
2016-02-26 13:37:25 -08:00
2016-07-13 11:24:10 -07:00
2016-07-13 11:24:10 -07:00
2016-07-19 13:22:16 -07:00
2016-05-17 14:38:28 -07:00
2016-04-29 12:59:09 -07:00