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 61031431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 06:59:39 -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 c0HOizizR60d for <notmuch@notmuchmail.org>;
\r
16 Mon, 24 Dec 2012 06:59:37 -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 6965E431FAE
\r
21 for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 06:59:37 -0800 (PST)
\r
22 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([156.34.82.78] 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 1Tn9V9-0000TU-N8; Mon, 24 Dec 2012 10:59:36 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>)
\r
30 id 1Tn9V4-0001kf-6i; Mon, 24 Dec 2012 10:59:30 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [Patch v2 3/4] perf-test: initial version of memory test
\r
35 Date: Mon, 24 Dec 2012 10:59:19 -0400
\r
36 Message-Id: <1356361160-6449-4-git-send-email-david@tethera.net>
\r
37 X-Mailer: git-send-email 1.7.10.4
\r
38 In-Reply-To: <1356361160-6449-1-git-send-email-david@tethera.net>
\r
39 References: <1356361160-6449-1-git-send-email-david@tethera.net>
\r
41 Cc: David Bremner <bremner@debian.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Mon, 24 Dec 2012 14:59:39 -0000
\r
56 From: David Bremner <bremner@debian.org>
\r
58 The idea is run some code under valgrind --leak-check=full and report
\r
59 a summary, leaving the user to peruse the log file if they want.
\r
61 We go to some lengths to preserve the log files from accidental
\r
62 overwriting; the full corpus takes about 3 hours to run under valgrind
\r
65 The naming of the log directories may be slightly controversial; in
\r
66 the unlikely event of two runs in less than a second, the log will be
\r
67 overwritten. A previous version with mktemp+timestamp was dismissed as
\r
68 overkill; just mktemp alone does not sort nicely.
\r
70 One new test is included, to check notmuch new for memory leaks.
\r
72 performance-test/.gitignore | 1 +
\r
73 performance-test/M00-new | 15 ++++++++
\r
74 performance-test/Makefile.local | 16 ++++++--
\r
75 performance-test/README | 57 +++++++++++++++++++---------
\r
76 performance-test/perf-test-lib.sh | 75 ++++++++++++++++++++++++++++---------
\r
77 5 files changed, 126 insertions(+), 38 deletions(-)
\r
78 create mode 100755 performance-test/M00-new
\r
80 diff --git a/performance-test/.gitignore b/performance-test/.gitignore
\r
81 index 6421a9a..f3f9be4 100644
\r
82 --- a/performance-test/.gitignore
\r
83 +++ b/performance-test/.gitignore
\r
89 diff --git a/performance-test/M00-new b/performance-test/M00-new
\r
90 new file mode 100755
\r
91 index 0000000..99c3f52
\r
93 +++ b/performance-test/M00-new
\r
97 +test_description='notmuch new'
\r
99 +. ./perf-test-lib.sh
\r
101 +# ensure initial 'notmuch new' is run by memory_start
\r
106 +# run 'notmuch new' a second time, to test different code paths
\r
107 +memory_run "notmuch new" "notmuch new"
\r
110 diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local
\r
111 index 57beb44..73aa963 100644
\r
112 --- a/performance-test/Makefile.local
\r
113 +++ b/performance-test/Makefile.local
\r
114 @@ -4,14 +4,24 @@ dir := performance-test
\r
116 include $(dir)/version.sh
\r
118 +TIME_TEST_SCRIPT := ${dir}/notmuch-time-test
\r
119 +MEMORY_TEST_SCRIPT := ${dir}/notmuch-memory-test
\r
121 CORPUS_NAME := notmuch-email-corpus-$(PERFTEST_VERSION).tar.xz
\r
122 TXZFILE := ${dir}/download/${CORPUS_NAME}
\r
123 SIGFILE := ${TXZFILE}.asc
\r
124 -TEST_SCRIPT := ${dir}/notmuch-perf-test
\r
125 DEFAULT_URL := http://notmuchmail.org/releases/${CORPUS_NAME}
\r
127 +perf-test: time-test memory-test
\r
129 time-test: setup-perf-test all
\r
130 - $(TEST_SCRIPT) $(OPTIONS)
\r
132 + $(TIME_TEST_SCRIPT) $(OPTIONS)
\r
134 +memory-test: setup-perf-test all
\r
136 + $(MEMORY_TEST_SCRIPT) $(OPTIONS)
\r
139 .PHONY: download-corpus setup-perf-test
\r
141 @@ -29,4 +39,4 @@ $(TXZFILE):
\r
143 wget -O ${TXZFILE} ${DEFAULT_URL}
\r
145 -CLEAN := $(CLEAN) $(dir)/tmp.* $(dir)/corpus $(dir)/notmuch.cache.*
\r
146 +CLEAN := $(CLEAN) $(dir)/tmp.* $(dir)/log.* $(dir)/corpus $(dir)/notmuch.cache.*
\r
147 diff --git a/performance-test/README b/performance-test/README
\r
148 index d1fb6de..996724c 100644
\r
149 --- a/performance-test/README
\r
150 +++ b/performance-test/README
\r
155 +This directory contains two kinds of performance tests: time tests,
\r
156 +and memory tests. The former use gnu time, and the latter use
\r
162 @@ -5,9 +12,10 @@ In addition to having notmuch, you need:
\r
167 +- gnu time (for the time tests)
\r
168 - xz. Some speedup can be gotten by installing "pixz", but this is
\r
169 probably only worthwhile if you are debugging the tests.
\r
170 +- valgrind (for the memory tests)
\r
172 Getting set up to run tests:
\r
173 ----------------------------
\r
174 @@ -36,34 +44,47 @@ for a list of mirrors.
\r
178 -The easiest way to run performance tests is to say "make time-test", (or
\r
179 -simply run the notmuch-time-test script). Either command will run all
\r
180 -available performance tests.
\r
182 -Alternately, you can run a specific subset of tests by simply invoking
\r
183 -one of the executable scripts in this directory, (such as ./basic).
\r
184 -Each test script supports the following arguments
\r
185 +The easiest way to run performance tests is to say "make perf-test".
\r
186 +This will run all time and memory tests. Be aware that the memory
\r
187 +tests are quite time consuming when run on the full corpus, and that
\r
188 +depending on your interests it may be more sensible to run "make
\r
189 +time-test" or "make memory-test". You can also invoke one of the
\r
190 +scripts notmuch-time-test or notmuch-memory-test or run a more
\r
191 +specific subset of tests by simply invoking one of the executable
\r
192 +scripts in this directory, (such as ./T00-new). Each test script
\r
193 +supports the following arguments
\r
195 --small / --medium / --large Choose corpus size.
\r
196 --debug Enable debugging. In particular don't delete
\r
197 temporary directories.
\r
199 +When using the make targets, you can pass arguments to all test
\r
200 +scripts by defining the make variable OPTIONS.
\r
205 -Have a look at "T01-dump-restore" for an example. Sourcing
\r
206 -"perf-test-lib.sh" is mandatory. Utility functions include
\r
207 +Have a look at "T01-dump-restore" for an example time test and
\r
208 +"M00-new" for an example memory test. In both cases sourcing
\r
209 +"perf-test-lib.sh" is mandatory.
\r
211 -- 'add_email_corpus' unpacks a set of messages and adds them to the database.
\r
212 -- 'cache_database': makes a snapshot of the current database
\r
213 -- 'uncache_database': forces the next 'add_email_corpus' to rebuild the
\r
215 -- 'time_start' unpacks the mail corpus and calls notmuch new if it
\r
218 +- '(time|memory)_start' unpacks the mail corpus and calls notmuch new if it
\r
219 cannot find a cache of the appropriate corpus.
\r
220 -- 'time_done' does the cleanup; comment it out or pass --debug to the
\r
221 +- '(time|memory)_run' runs the command under time or valgrind. Currently
\r
222 + "memory_run" does not support i/o redirection in the command.
\r
223 +- '(time|memory)_done' does the cleanup; comment it out or pass --debug to the
\r
224 script to leave the temporary files around.
\r
226 +Utility functions include
\r
228 +- 'add_email_corpus' unpacks a set of messages and tags
\r
229 +- 'cache_database': makes a snapshot of the current database
\r
230 +- 'uncache_database': forces the next '(time|memory)_start' to rebuild the
\r
233 Scripts are run in the order specified in notmuch-perf-test. In the
\r
234 future this order might be chosen automatically so please follow the
\r
235 -convention of starting the name with 'T' followed by two digits to
\r
236 -specify the order.
\r
237 +convention of starting the name with 'T' or 'M' followed by two digits
\r
238 +to specify the order.
\r
239 diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh
\r
240 index 3a7ef2b..10d05e0 100644
\r
241 --- a/performance-test/perf-test-lib.sh
\r
242 +++ b/performance-test/perf-test-lib.sh
\r
243 @@ -89,24 +89,59 @@ add_email_corpus ()
\r
245 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
\r
246 cp -lr $MAIL_CORPUS $MAIL_DIR
\r
256 +notmuch_new_with_cache ()
\r
258 if [ -d $DB_CACHE_DIR ]; then
\r
259 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
\r
261 - time_run 'Initial notmuch new' "notmuch new"
\r
262 + "$1" 'Initial notmuch new' "notmuch new"
\r
267 -cache_database () {
\r
274 + notmuch_new_with_cache time_run
\r
281 + local timestamp=$(date +%Y%m%dT%H%M%S)
\r
282 + log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
\r
283 + mkdir -p ${log_dir}
\r
285 + notmuch_new_with_cache memory_run
\r
290 + test_count=$(($test_count+1))
\r
292 + log_file=$log_dir/$test_count.log
\r
294 + printf "[ %d ]\t%s\n" $test_count "$1"
\r
296 + valgrind --leak-check=full --log-file="$log_file" $2
\r
298 + awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
\r
309 if [ -d $MAIL_DIR/.notmuch ]; then
\r
310 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
\r
312 @@ -114,17 +149,20 @@ cache_database () {
\r
316 -uncache_database () {
\r
317 +uncache_database ()
\r
319 rm -rf $DB_CACHE_DIR
\r
323 - printf "[v%4s %6s] Wall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n" \
\r
324 - ${PERFTEST_VERSION} ${corpus_size}
\r
327 + printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
\r
333 printf " %-22s" "$1"
\r
334 + test_count=$(($test_count+1))
\r
335 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
\r
336 if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
\r
337 test_failure=$(($test_failure + 1))
\r
338 @@ -133,7 +171,8 @@ time_run () {
\r
345 if [ "$test_failure" = "0" ]; then
\r
346 rm -rf "$remove_tmp"
\r
348 @@ -144,6 +183,8 @@ time_done () {
\r
350 cd -P "$test" || error "Cannot setup test environment"
\r
355 -echo $(basename "$0"): "Testing ${test_description:-notmuch performance}"
\r
356 +printf "\n%-55s [%s %s]\n" \
\r
357 + "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
\r
358 + "${PERFTEST_VERSION}" "${corpus_size}"
\r