summaryrefslogtreecommitdiff
path: root/builtin/index-pack.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-08-31 15:49:48 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-08-31 15:49:48 -0700
commit53015c9dd40e0a5afc14aeeb6e6def25f10fff4d (patch)
treef3c01bfad2ae5b61e4c316c54a48ef831aea05dd /builtin/index-pack.c
parentMerge branch 'hv/ref-filter-trailers-atom-parsing-fix' (diff)
parentindex-pack: adjust default threading cap (diff)
downloadtgif-53015c9dd40e0a5afc14aeeb6e6def25f10fff4d.tar.xz
Merge branch 'jk/index-pack-w-more-threads'
Long ago, we decided to use 3 threads by default when running the index-pack task in parallel, which has been adjusted a bit upwards. * jk/index-pack-w-more-threads: index-pack: adjust default threading cap p5302: count up to online-cpus for thread tests p5302: disable thread-count parameter tests by default
Diffstat (limited to 'builtin/index-pack.c')
-rw-r--r--builtin/index-pack.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index f865666db9..9721bf1ffe 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1798,9 +1798,22 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
if (HAVE_THREADS && !nr_threads) {
nr_threads = online_cpus();
- /* An experiment showed that more threads does not mean faster */
- if (nr_threads > 3)
- nr_threads = 3;
+ /*
+ * Experiments show that going above 20 threads doesn't help,
+ * no matter how many cores you have. Below that, we tend to
+ * max at half the number of online_cpus(), presumably because
+ * half of those are hyperthreads rather than full cores. We'll
+ * never reduce the level below "3", though, to match a
+ * historical value that nobody complained about.
+ */
+ if (nr_threads < 4)
+ ; /* too few cores to consider capping */
+ else if (nr_threads < 6)
+ nr_threads = 3; /* historic cap */
+ else if (nr_threads < 40)
+ nr_threads /= 2;
+ else
+ nr_threads = 20; /* hard cap */
}
curr_pack = open_pack_file(pack_name);