From 43cc2b4266cc75f1a5a10e1a805d05e419000573 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 11 Dec 2008 15:36:47 -0500 Subject: [PATCH 1/3] autodetect number of CPUs by default when using threads ... and display the actual number of threads used when locally repacking. A remote server still won't tell you how many threads it uses during a fetch though. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- builtin-pack-objects.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index cedef52fd..619e597d5 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -78,7 +78,7 @@ static int progress = 1; static int window = 10; static uint32_t pack_size_limit, pack_size_limit_cfg; static int depth = 50; -static int delta_search_threads = 1; +static int delta_search_threads; static int pack_to_stdout; static int num_preferred_base; static struct progress *progress_state; @@ -1612,6 +1612,9 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, find_deltas(list, &list_size, window, depth, processed); return; } + if (progress > pack_to_stdout) + fprintf(stderr, "Delta compression using %d threads.\n", + delta_search_threads); /* Partition the work amongst work threads. */ for (i = 0; i < delta_search_threads; i++) { From bf874896240cb00b22cd4f6cbcc143b17cc7fe0e Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Sat, 13 Dec 2008 15:06:40 -0500 Subject: [PATCH 2/3] pack-objects: don't use too many threads with few objects If there are few objects to deltify, they might be split amongst threads so that there is simply no other objects left to delta against within the same thread. Let's use the same 2*window treshold as used for the final load balancing to allow extra threads to be created. This fixes the benign t5300 test failure. Signed-off-by: Nicolas Pitre Tested-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-pack-objects.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 619e597d5..e8515348b 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -1620,6 +1620,10 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, for (i = 0; i < delta_search_threads; i++) { unsigned sub_size = list_size / (delta_search_threads - i); + /* don't use too small segments or no deltas will be found */ + if (sub_size < 2*window && i+1 < delta_search_threads) + sub_size = 0; + p[i].window = window; p[i].depth = depth; p[i].processed = processed; From 1415be8f0f86c6d2aa2cb014c3cc32dd92e9c43a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 15 Dec 2008 20:44:30 +0100 Subject: [PATCH 3/3] Force t5302 to use a single thread If the packs are made using multiple threads, they are no longer identical on the 4-core Xeon I tested on. Signed-off-by: Johannes Schindelin Acked-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- t/t5302-pack-index.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 884e24253..e6f70d474 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -10,6 +10,7 @@ test_expect_success \ 'setup' \ 'rm -rf .git git init && + git config pack.threads 1 && i=1 && while test $i -le 100 do