1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 988EB429E26
\r
6 for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 10:23:59 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id ftMJZPQfbZnT for <notmuch@notmuchmail.org>;
\r
16 Sun, 16 Dec 2012 10:23:57 -0800 (PST)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id AF86B429E2F
\r
21 for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 10:23:56 -0800 (PST)
\r
22 Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([142.167.90.129] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)
\r
26 (envelope-from <bremner@tethera.net>)
\r
27 id 1TkIsV-0007mx-GU; Sun, 16 Dec 2012 14:23:56 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>)
\r
30 id 1TkIsQ-0003cY-0U; Sun, 16 Dec 2012 14:23:50 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH 3/4] perf-test: initial version of memory test infrastructure.
\r
34 Date: Sun, 16 Dec 2012 14:23:27 -0400
\r
35 Message-Id: <1355682208-13729-4-git-send-email-david@tethera.net>
\r
36 X-Mailer: git-send-email 1.7.10.4
\r
37 In-Reply-To: <1355682208-13729-1-git-send-email-david@tethera.net>
\r
38 References: <1355682208-13729-1-git-send-email-david@tethera.net>
\r
40 Cc: David Bremner <bremner@debian.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Sun, 16 Dec 2012 18:24:00 -0000
\r
55 From: David Bremner <bremner@debian.org>
\r
57 The idea is run some code under valgrind --leak-check=full and report
\r
58 a summary, leaving the user to peruse the log file if they want.
\r
60 We go to some lengths to preserve the log files from accidental
\r
61 overwriting; the full corpus takes about 3 hours to run under valgrind
\r
64 The naming of the log directories is probably overkill; I find it nice
\r
65 to have them sequenced by time. Arguably the mktemp is then overkill,
\r
66 but I know people will be nervous if it looks like timestamps are
\r
67 being used for uniqueness.
\r
69 One new test is included, to check notmuch new for memory leaks.
\r
71 performance-test/.gitignore | 1 +
\r
72 performance-test/M00-new | 14 +++++++++
\r
73 performance-test/Makefile.local | 17 +++++++++--
\r
74 performance-test/README | 57 +++++++++++++++++++++++++------------
\r
75 performance-test/perf-test-lib.sh | 55 ++++++++++++++++++++++++++++-------
\r
76 5 files changed, 113 insertions(+), 31 deletions(-)
\r
77 create mode 100755 performance-test/M00-new
\r
79 diff --git a/performance-test/.gitignore b/performance-test/.gitignore
\r
80 index 6421a9a..f3f9be4 100644
\r
81 --- a/performance-test/.gitignore
\r
82 +++ b/performance-test/.gitignore
\r
88 diff --git a/performance-test/M00-new b/performance-test/M00-new
\r
89 new file mode 100755
\r
90 index 0000000..733e9b0
\r
92 +++ b/performance-test/M00-new
\r
96 +test_description='notmuch new'
\r
98 +. ./perf-test-lib.sh
\r
100 +# ensure initial 'notmuch new' is run by memory_start
\r
105 +memory_run "notmuch new" "notmuch new"
\r
108 diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local
\r
109 index 57beb44..357d800 100644
\r
110 --- a/performance-test/Makefile.local
\r
111 +++ b/performance-test/Makefile.local
\r
112 @@ -4,14 +4,25 @@ dir := performance-test
\r
114 include $(dir)/version.sh
\r
116 +# these two are just make sure dir is expanded at the right time.
\r
117 +TIME_TEST_SCRIPT := ${dir}/notmuch-time-test
\r
118 +MEMORY_TEST_SCRIPT := ${dir}/notmuch-memory-test
\r
120 CORPUS_NAME := notmuch-email-corpus-$(PERFTEST_VERSION).tar.xz
\r
121 TXZFILE := ${dir}/download/${CORPUS_NAME}
\r
122 SIGFILE := ${TXZFILE}.asc
\r
123 -TEST_SCRIPT := ${dir}/notmuch-perf-test
\r
124 DEFAULT_URL := http://notmuchmail.org/releases/${CORPUS_NAME}
\r
126 +perf-test: time-test memory-test
\r
128 time-test: setup-perf-test all
\r
129 - $(TEST_SCRIPT) $(OPTIONS)
\r
131 + $(TIME_TEST_SCRIPT) $(TEST_OPTIONS)
\r
133 +memory-test: setup-perf-test all
\r
135 + $(MEMORY_TEST_SCRIPT) $(TEST_OPTIONS)
\r
138 .PHONY: download-corpus setup-perf-test
\r
140 @@ -29,4 +40,4 @@ $(TXZFILE):
\r
142 wget -O ${TXZFILE} ${DEFAULT_URL}
\r
144 -CLEAN := $(CLEAN) $(dir)/tmp.* $(dir)/corpus $(dir)/notmuch.cache.*
\r
145 +CLEAN := $(CLEAN) $(dir)/tmp.* $(dir)/log.* $(dir)/corpus $(dir)/notmuch.cache.*
\r
146 diff --git a/performance-test/README b/performance-test/README
\r
147 index d1fb6de..7eaf5f7 100644
\r
148 --- a/performance-test/README
\r
149 +++ b/performance-test/README
\r
154 +This directory contains two kinds of performance tests, time tests,
\r
155 +and memory tests. The former use gnu time, and the latter use
\r
161 @@ -5,9 +12,10 @@ In addition to having notmuch, you need:
\r
166 +- gnu time (for the time tests).
\r
167 - xz. Some speedup can be gotten by installing "pixz", but this is
\r
168 probably only worthwhile if you are debugging the tests.
\r
169 +- valgrind (for the memory tests)
\r
171 Getting set up to run tests:
\r
172 ----------------------------
\r
173 @@ -36,34 +44,47 @@ for a list of mirrors.
\r
177 -The easiest way to run performance tests is to say "make time-test", (or
\r
178 -simply run the notmuch-time-test script). Either command will run all
\r
179 -available performance tests.
\r
181 -Alternately, you can run a specific subset of tests by simply invoking
\r
182 -one of the executable scripts in this directory, (such as ./basic).
\r
183 -Each test script supports the following arguments
\r
184 +The easiest way to run performance tests is to say "make perf-test".
\r
185 +This will run all time and memory tests. Be aware that the memory
\r
186 +tests are quite time consuming when run on the full corpus, and that
\r
187 +depending on your interests it may be more sensible to run "make
\r
188 +time-test" or "make memory-test". You can also invoke one of the
\r
189 +scripts notmuch-time-test or notmuch-memory-test or run a more
\r
190 +specific subset of tests by simply invoking one of the executable
\r
191 +scripts in this directory, (such as ./T00-new). Each test script
\r
192 +supports the following arguments
\r
194 --small / --medium / --large Choose corpus size.
\r
195 --debug Enable debugging. In particular don't delete
\r
196 temporary directories.
\r
198 +When using the make targets, you can pass arguments to all test
\r
199 +scripts by defining the make variable TEST_OPTIONS.
\r
204 -Have a look at "T01-dump-restore" for an example. Sourcing
\r
205 -"perf-test-lib.sh" is mandatory. Utility functions include
\r
206 +Have a look at "T01-dump-restore" for an example time test and and
\r
207 +"M00-new" for an example memory tests. In both cases sourcing
\r
208 +"perf-test-lib.sh" is mandatory.
\r
210 -- 'add_email_corpus' unpacks a set of messages and adds them to the database.
\r
211 -- 'cache_database': makes a snapshot of the current database
\r
212 -- 'uncache_database': forces the next 'add_email_corpus' to rebuild the
\r
214 -- 'time_start' unpacks the mail corpus and calls notmuch new if it
\r
217 +- '(time|memory)_start' unpacks the mail corpus and calls notmuch new if it
\r
218 cannot find a cache of the appropriate corpus.
\r
219 -- 'time_done' does the cleanup; comment it out or pass --debug to the
\r
220 +- '(time|memory)_run' runs the command under time or valgrind. Currently
\r
221 + "memory_run" does not support i/o redirection in the command.
\r
222 +- '(time|memory)_done' does the cleanup; comment it out or pass --debug to the
\r
223 script to leave the temporary files around.
\r
225 +Utility functions include
\r
227 +- 'add_email_corpus' unpacks a set of messages and tags
\r
228 +- 'cache_database': makes a snapshot of the current database
\r
229 +- 'uncache_database': forces the next '(time|memory)_start' to rebuild the
\r
232 Scripts are run in the order specified in notmuch-perf-test. In the
\r
233 future this order might be chosen automatically so please follow the
\r
234 -convention of starting the name with 'T' followed by two digits to
\r
235 -specify the order.
\r
236 +convention of starting the name with 'T' or 'M' followed by two digits
\r
237 +to specify the order.
\r
238 diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh
\r
239 index 3a7ef2b..79eb2c5 100644
\r
240 --- a/performance-test/perf-test-lib.sh
\r
241 +++ b/performance-test/perf-test-lib.sh
\r
242 @@ -92,20 +92,52 @@ add_email_corpus ()
\r
251 +notmuch_new_with_cache () {
\r
253 if [ -d $DB_CACHE_DIR ]; then
\r
254 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
\r
256 - time_run 'Initial notmuch new' "notmuch new"
\r
257 + "$1" 'Initial notmuch new' "notmuch new"
\r
268 + notmuch_new_with_cache time_run
\r
275 + _timestamp=$(printf "%x" $(date +"%s"))
\r
276 + log_dir=$(mktemp -d "${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${_timestamp}-XXXXXX")
\r
278 + notmuch_new_with_cache memory_run
\r
282 + test_count=$(($test_count+1))
\r
284 + log_file=$log_dir/$test_count.log
\r
286 + printf "[ %d ]\t%s\n" $test_count "$1"
\r
288 + valgrind --leak-check=full --log-file="$log_file" $2
\r
290 + awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
\r
298 cache_database () {
\r
299 if [ -d $MAIL_DIR/.notmuch ]; then
\r
300 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
\r
301 @@ -119,12 +151,13 @@ uncache_database () {
\r
305 - printf "[v%4s %6s] Wall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n" \
\r
306 - ${PERFTEST_VERSION} ${corpus_size}
\r
307 + printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
\r
312 printf " %-22s" "$1"
\r
313 + test_count=$(($test_count+1))
\r
314 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
\r
315 if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
\r
316 test_failure=$(($test_failure + 1))
\r
317 @@ -144,6 +177,8 @@ time_done () {
\r
319 cd -P "$test" || error "Cannot setup test environment"
\r
324 -echo $(basename "$0"): "Testing ${test_description:-notmuch performance}"
\r
325 +printf "\n%-55s [%s %s]\n" \
\r
326 + "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
\r
327 + "${PERFTEST_VERSION}" "${corpus_size}"
\r