From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [kvm-unit-tests PATCH 2/2] run_tests: allow run tests in parallel Date: Mon, 2 Jan 2017 21:18:24 +0100 Message-ID: <20170102201824.GA2892@potion> References: <1483266886-25050-1-git-send-email-peterx@redhat.com> <1483266886-25050-3-git-send-email-peterx@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paolo Bonzini , Andrew Jones , qemu-devel@nongnu.org, kvm@vger.kernel.org To: Peter Xu Return-path: Content-Disposition: inline In-Reply-To: <1483266886-25050-3-git-send-email-peterx@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org 2017-01-01 18:34+0800, Peter Xu: > run_task.sh is getting slow. This patch is trying to make it faster by > running the tests concurrently. > > First of all, we provide a new parameter "-j" for the run_tests.sh, > which can be used to specify how many run queues we want for the tests. > When "-j" is not provided, we'll keep the old behavior. > > When the tests are running concurrently, we will use seperate log file > for each test case (currently located in logs/ dir, with name > test.TESTNAME.log), to avoid test logs messing up with each other. > > A quick test on my laptop (x86 with 4 cores and 2 threads, so 8 > processors) shows 3x improvement on overall test time: > > |-----------------+-----------| > | command | time used | > |-----------------+-----------| > | run_test.sh | 75s | > | run_test.sh -j8 | 27s | > |-----------------+-----------| > > Signed-off-by: Peter Xu > --- > diff --git a/scripts/functions.bash b/scripts/functions.bash > @@ -1,7 +1,18 @@ > +source scripts/global.bash > +source scripts/task.bash > + > function run_task() > { > - RUNTIME_log_file=$ut_default_log_file > - "$@" > + local testname="$2" > + > + if ut_in_parallel; then > + RUNTIME_log_file="${ut_log_dir}/test.${testname}.log" No need for the "test." prefix. I would do this change regardless of ut_in_parallel. Having output of all tests in one file just wasted time when most usecases were to find a specific failed test. > + # run in background > + task_enqueue "$@" Couldn't the queue be much simpler ... > + else > + RUNTIME_log_file=$ut_default_log_file > + "$@" > + fi > } > > function for_each_unittest() > @@ -51,5 +62,10 @@ function for_each_unittest() > fi > done ... like this: while [ "`jobs | wc -l`" -gt $ut_run_queues ]; do wait done run_task "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" & ? (default $ut_run_queues would be 1) > run_task "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" > + > + if ut_in_parallel; then > + task_wait_all > + fi > + > exec {fd}<&- > }