]> git.ipfire.org Git - thirdparty/git.git/commit
chainlint.pl: only start threads if jobs > 1
authorJeff King <peff@peff.net>
Wed, 10 Jul 2024 08:35:13 +0000 (04:35 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jul 2024 17:14:21 +0000 (10:14 -0700)
commita7c1c102562c141b752f06f94c99438fa80319e8
treeb182042954996151d47eba3f1905289f26e03188
parenta5e450144dbc85b5cd7b0e01c6aa7fd30f117ee2
chainlint.pl: only start threads if jobs > 1

If the system supports threads, chainlint.pl will always spawn worker
threads to do the real work. But when --jobs=1, this is pointless, since
we could just do the work in the main thread. And spawning even a single
thread has a high overhead. For example, on my Linux system, running:

  for i in chainlint/*.test; do
perl chainlint.pl --jobs=1 $i
  done >/dev/null

takes ~1.7s without this patch, and ~1.1s after. We don't usually spawn
a bunch of individual chainlint.pl processes (instead we feed several
scripts at once, and the parallelism outweighs the setup cost). But it's
something we've considered doing, and since we already have fallback
code for systems without thread support, it's pretty easy to make this
work.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/chainlint.pl