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 <peterx@xxxxxxxxxx> > --- > 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}<&- > } -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html