All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pack-objects: Use reachability bitmap index when generating non-stdout pack too
@ 2016-07-07 19:09 Kirill Smelkov
  2016-07-07 20:52 ` Jeff King
  0 siblings, 1 reply; 62+ messages in thread
From: Kirill Smelkov @ 2016-07-07 19:09 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Jérome Perrin, Isabelle Vallet, Kazuhiko Shiozaki,
	Julien Muchembled, git, Kirill Smelkov, Vicent Marti, Jeff King

Starting from 6b8fda2d (pack-objects: use bitmaps when packing objects)
if a repository has bitmap index, pack-objects can nicely speedup
"Counting objects" graph traversal phase. That however was done only for
case when resultant pack is sent to stdout, not written into a file.

We can teach pack-objects to use bitmap index for initial object
counting phase when generating resultant pack file too:

- if we know bitmap index generation is not enabled for resultant pack:

  Current code has singleton bitmap_git so cannot work simultaneously
  with two bitmap indices.

- if we keep pack reuse enabled still only for "send-to-stdout" case:

  Because on pack reuse raw entries are directly written out to destination
  pack by write_reused_pack() bypassing needed for pack index generation
  bookkeeping done by regular codepath in write_one() and friends.

  (at least that's my understanding after briefly looking at the code)

We also need to care and teach add_object_entry_from_bitmap() to respect
--local via not adding nonlocal loose object to resultant pack (this
is bitmap-codepath counterpart of daae0625 (pack-objects: extend --local
to mean ignore non-local loose objects too) -- not to break 'loose
objects in alternate ODB are not repacked' in t7700-repack.sh .

Otherwise all git tests pass, and for pack-objects -> file we get nice
speedup:

    erp5.git[1] (~230MB) extracted from ~ 5GB lab.nexedi.com backup
    repository managed by git-backup[2] via

    time echo 0186ac99 | git pack-objects --revs erp5pack

before:  37.2s
after:   26.2s

And for `git repack -adb` packed git.git

    time echo 5c589a73 | git pack-objects --revs gitpack

before:   7.1s
after:    3.6s

i.e. it can be 30% - 50% speedup for pack extraction.

git-backup extracts many packs on repositories restoration. That was my
initial motivation for the patch.

[1] https://lab.nexedi.com/nexedi/erp5
[2] https://lab.nexedi.com/kirr/git-backup

Cc: Vicent Marti <tanoku@gmail.com>
Cc: Jeff King <peff@peff.net>
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
---
 builtin/pack-objects.c  | 7 +++++--
 t/t5310-pack-bitmaps.sh | 9 +++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a2f8cfd..be0ebe8 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1052,6 +1052,9 @@ static int add_object_entry_from_bitmap(const unsigned char *sha1,
 {
 	uint32_t index_pos;
 
+	if (local && has_loose_object_nonlocal(sha1))
+		return 0;
+
 	if (have_duplicate_entry(sha1, 0, &index_pos))
 		return 0;
 
@@ -2488,7 +2491,7 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
 	if (prepare_bitmap_walk(revs) < 0)
 		return -1;
 
-	if (pack_options_allow_reuse() &&
+	if (pack_options_allow_reuse() && pack_to_stdout &&
 	    !reuse_partial_packfile_from_bitmap(
 			&reuse_packfile,
 			&reuse_packfile_objects,
@@ -2773,7 +2776,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	if (!rev_list_all || !rev_list_reflog || !rev_list_index)
 		unpack_unreachable_expiration = 0;
 
-	if (!use_internal_rev_list || !pack_to_stdout || is_repository_shallow())
+	if (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow())
 		use_bitmap_index = 0;
 
 	if (pack_to_stdout || !rev_list_all)
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 3893afd..533fc31 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -118,6 +118,15 @@ test_expect_success 'incremental repack can disable bitmaps' '
 	git repack -d --no-write-bitmap-index
 '
 
+test_expect_success 'pack-objects to file can use bitmap' '
+	# make sure we still have 1 bitmap index from previous tests
+	ls .git/objects/pack/ | grep bitmap >output &&
+	test_line_count = 1 output &&
+	# pack-objects uses bitmap index by default, when it is available
+	packsha1=$(git pack-objects --all mypack </dev/null) &&
+	git verify-pack mypack-$packsha1.pack
+'
+
 test_expect_success 'full repack, reusing previous bitmaps' '
 	git repack -ad &&
 	ls .git/objects/pack/ | grep bitmap >output &&
-- 
2.9.0.431.gb11dac7.dirty

^ permalink raw reply related	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2016-09-13  7:50 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-07 19:09 [PATCH] pack-objects: Use reachability bitmap index when generating non-stdout pack too Kirill Smelkov
2016-07-07 20:52 ` Jeff King
2016-07-08 10:38   ` Kirill Smelkov
2016-07-12 19:08     ` Kirill Smelkov
2016-07-13  8:30       ` Jeff King
2016-07-13  8:26     ` Jeff King
2016-07-13 10:52       ` Kirill Smelkov
2016-07-17 17:06         ` Kirill Smelkov
2016-07-19 11:29           ` Jeff King
2016-07-19 12:14             ` Kirill Smelkov
2016-07-25 18:40         ` Jeff King
2016-07-25 18:53           ` Jeff King
2016-07-27 20:15           ` Kirill Smelkov
2016-07-27 20:40             ` Junio C Hamano
2016-07-28 20:22               ` Kirill Smelkov
2016-07-28 21:18                 ` Junio C Hamano
2016-07-29  7:40                   ` Kirill Smelkov
2016-07-29  7:46                     ` [PATCH 1/2] pack-objects: Teach --use-bitmap-index codepath to respect --local, --honor-pack-keep and --incremental Kirill Smelkov
2016-08-01 18:17                       ` Junio C Hamano
2016-08-08 12:37                         ` Kirill Smelkov
2016-08-08 13:50                           ` Jeff King
2016-08-08 13:51                             ` Jeff King
2016-08-08 16:08                             ` Junio C Hamano
2016-08-08 19:06                             ` Junio C Hamano
2016-08-08 19:09                               ` Jeff King
2016-08-08 16:11                           ` Junio C Hamano
2016-08-08 18:19                             ` Kirill Smelkov
2016-08-08 18:57                               ` [PATCH v3] " Kirill Smelkov
2016-08-08 19:26                               ` [PATCH 1/2] " Junio C Hamano
2016-08-09 11:21                                 ` Kirill Smelkov
2016-08-09 11:25                                   ` [PATCH 1/2 v4] pack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use Kirill Smelkov
2016-08-09 16:52                                   ` [PATCH 1/2] pack-objects: Teach --use-bitmap-index codepath to respect --local, --honor-pack-keep and --incremental Junio C Hamano
2016-08-09 19:29                                     ` Kirill Smelkov
2016-08-09 19:31                                       ` [PATCH 1/2 v5] pack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use Kirill Smelkov
2016-08-18 17:52                                         ` Jeff King
2016-09-10 14:57                                           ` Kirill Smelkov
2016-09-10 15:01                                             ` [PATCH 1/2 v8] " Kirill Smelkov
2016-09-13  6:23                                               ` Junio C Hamano
2016-09-13  7:50                                                 ` Kirill Smelkov
2016-09-10 15:05                                             ` [PATCH] t/perf/run: Don't forget to copy config.mak.autogen & friends to build area Kirill Smelkov
2016-09-12 19:12                                               ` Junio C Hamano
2016-09-12 19:17                                                 ` Junio C Hamano
2016-09-12 23:10                                                   ` Junio C Hamano
2016-09-13  6:58                                                     ` Kirill Smelkov
2016-09-12 17:33                                             ` [PATCH 1/2 v5] pack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use Junio C Hamano
2016-08-09 19:32                                       ` [PATCH 2/2 v7] pack-objects: use reachability bitmap index when generating non-stdout pack Kirill Smelkov
2016-08-18 18:06                                         ` Jeff King
2016-09-10 14:59                                           ` Kirill Smelkov
2016-09-10 15:01                                             ` [PATCH 2/2 v8] " Kirill Smelkov
2016-09-12 19:21                                             ` [PATCH 2/2 v7] " Junio C Hamano
2016-08-09 19:49                                       ` [PATCH 1/2] pack-objects: Teach --use-bitmap-index codepath to respect --local, --honor-pack-keep and --incremental Junio C Hamano
2016-07-29  7:47                     ` [PATCH v4 2/2] pack-objects: Teach it to use reachability bitmap index when generating non-stdout pack too Kirill Smelkov
2016-08-08 13:56                       ` Jeff King
2016-08-08 15:40                         ` Kirill Smelkov
2016-08-08 18:08                           ` Junio C Hamano
2016-08-08 18:13                             ` Kirill Smelkov
2016-08-08 18:28                               ` Junio C Hamano
2016-08-08 18:58                                 ` Kirill Smelkov
2016-08-08 18:55                           ` [PATCH v5] pack-objects: teach " Kirill Smelkov
2016-08-08 20:53                             ` Junio C Hamano
2016-08-09 11:21                               ` Kirill Smelkov
2016-08-09 11:26                                 ` [PATCH 2/2 v6] pack-objects: use reachability bitmap index when generating non-stdout pack Kirill Smelkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.