Skip to content

Commit a7c1c10

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5e4501 commit a7c1c10

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

t/chainlint.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ sub exit_code {
807807
exit;
808808
}
809809

810-
unless ($Config{useithreads} && eval {
810+
unless ($jobs > 1 &&
811+
$Config{useithreads} && eval {
811812
require threads; threads->import();
812813
require Thread::Queue; Thread::Queue->import();
813814
1;

0 commit comments

Comments
 (0)