From: Peter Xu <peterx@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [Qemu-devel] [kvm-unit-tests PATCH v4 2/2] run_tests: allow run tests in parallel
Date: Wed, 11 Jan 2017 13:28:03 +0800 [thread overview]
Message-ID: <20170111052803.GB4450@pxdev.xzpeter.org> (raw)
In-Reply-To: <20170110173959.ckfhipadyv3bsijs@kamzik.brq.redhat.com>
On Tue, Jan 10, 2017 at 06:39:59PM +0100, Andrew Jones wrote:
> On Mon, Jan 09, 2017 at 12:04:54PM +0800, Peter Xu wrote:
> > run_task.sh is getting slow. This patch is trying to make it faster by
> > running the tests concurrently.
> >
> > 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. Default queue
> > length is 1, which is the old behavior.
> >
> > Quick test on my laptop (4 cores, 2 threads each) shows 3x speed boost:
> >
> > |-----------------+-----------|
> > | command | time used |
> > |-----------------+-----------|
> > | run_test.sh | 75s |
> > | run_test.sh -j8 | 27s |
> > |-----------------+-----------|
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > run_tests.sh | 12 ++++++++++--
> > scripts/common.bash | 16 +++++++++++++++-
> > 2 files changed, 25 insertions(+), 3 deletions(-)
> >
> > diff --git a/run_tests.sh b/run_tests.sh
> > index 1e36d66..795cf73 100755
> > --- a/run_tests.sh
> > +++ b/run_tests.sh
> > @@ -13,10 +13,11 @@ function usage()
> > {
> > cat <<EOF
> >
> > -Usage: $0 [-g group] [-h] [-v]
> > +Usage: $0 [-g group] [-h] [-v] [-j num_run_queues]
> >
> > -g: Only execute tests in the given group
> > -h: Output this help text
> > + -j: Execute tests in parallel
> > -v: Enables verbose mode
> >
> > Set the environment variable QEMU=/path/to/qemu-system-ARCH to
> > @@ -28,7 +29,7 @@ EOF
> > RUNTIME_arch_run="./$TEST_DIR/run"
> > source scripts/runtime.bash
> >
> > -while getopts "g:hv" opt; do
> > +while getopts "g:hj:v" opt; do
> > case $opt in
> > g)
> > only_group=$OPTARG
> > @@ -37,6 +38,13 @@ while getopts "g:hv" opt; do
> > usage
> > exit
> > ;;
> > + j)
> > + unittest_run_queues=$OPTARG
> > + if ! (( "$unittest_run_queues" > 0 )); then
>
> The equivalent expression without '!' is (( $var <= 0 )), and
> no need for the "'s around the var.
>
> > + echo "Invalid -j option: $unittest_run_queues"
> > + exit 1
> > + fi
> > + ;;
> > v)
> > verbose="yes"
> > ;;
> > diff --git a/scripts/common.bash b/scripts/common.bash
> > index 2dd7360..83aebf8 100644
> > --- a/scripts/common.bash
> > +++ b/scripts/common.bash
> > @@ -1,11 +1,19 @@
> > : ${unittest_log_dir:=logs}
> > +: ${unittest_run_queues:=1}
> >
> > function run_task()
> > {
> > local testname="$2"
> >
> > + while (( "$(jobs | wc -l)" == $unittest_run_queues )); do
>
> Why the "'s? The result must resolve to an int, otherwise we don't
> want ((...))
>
> > + # wait for any background test to finish
> > + wait -n
> > + done
> > +
> > RUNTIME_log_file="${unittest_log_dir}/${testname}.log"
> > - "$@"
> > +
> > + # start the testcase in the background
> > + "$@" &
> > }
> >
> > function for_each_unittest()
> > @@ -22,6 +30,8 @@ function for_each_unittest()
> > local accel
> > local timeout
> >
> > + trap "wait; exit 130" SIGINT
> > +
> > exec {fd}<"$unittests"
> >
> > while read -u $fd line; do
> > @@ -55,5 +65,9 @@ function for_each_unittest()
> > fi
> > done
> > run_task "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
> > +
> > + # wait all task finish
>
> wait until all tasks finish
Fixing all three places, thanks!
-- peterx
prev parent reply other threads:[~2017-01-11 5:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-09 4:04 [Qemu-devel] [kvm-unit-tests PATCH v4 0/2] run_tests: support concurrent test execution Peter Xu
2017-01-09 4:04 ` [Qemu-devel] [kvm-unit-tests PATCH v4 1/2] run_tests: put logs into per-test file Peter Xu
2017-01-10 17:28 ` Andrew Jones
2017-01-11 5:20 ` Peter Xu
2017-01-09 4:04 ` [Qemu-devel] [kvm-unit-tests PATCH v4 2/2] run_tests: allow run tests in parallel Peter Xu
2017-01-10 17:39 ` Andrew Jones
2017-01-11 5:28 ` Peter Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170111052803.GB4450@pxdev.xzpeter.org \
--to=peterx@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).