Skip to content

Commit d558509

Browse files
peffgitster
authored andcommitted
chainlint.pl: do not spawn more threads than we have scripts
The chainlint.pl script spawns worker threads to check many scripts in parallel. This is good if you feed it a lot of scripts. But if you give it few (or one), then the overhead of spawning the threads dominates. We can easily notice that we have fewer scripts than threads and scale back as appropriate. This patch reduces the time to run: time for i in chainlint/*.test; do perl chainlint.pl $i done >/dev/null on my system from ~4.1s to ~1.1s, where I have 8+8 cores. As with the previous patch, this isn't the usual way we run chainlint (we feed many scripts at once, which is why it supports threading in the first place). So this won't make a big difference in the real world, but it may help us out in the future, and it makes experimenting with and debugging the chainlint tests a bit more pleasant. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a7c1c10 commit d558509

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

t/chainlint.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ sub exit_code {
806806
show_stats($start_time, \@stats) if $show_stats;
807807
exit;
808808
}
809+
$jobs = @scripts if @scripts < $jobs;
809810

810811
unless ($jobs > 1 &&
811812
$Config{useithreads} && eval {

0 commit comments

Comments
 (0)