[PATCH v2 3/9] chainlint.pl: do not spawn more threads than we have scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <peff@xxxxxxxx>
---
 t/chainlint.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/t/chainlint.pl b/t/chainlint.pl
index 1864d048ae..118a229a96 100755
--- a/t/chainlint.pl
+++ b/t/chainlint.pl
@@ -806,6 +806,7 @@ sub exit_code {
 	show_stats($start_time, \@stats) if $show_stats;
 	exit;
 }
+$jobs = @scripts if @scripts < $jobs;
 
 unless ($jobs > 1 &&
 	$Config{useithreads} && eval {
-- 
2.45.2.1249.gb036353db5





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux