2012-11-17 17:28:15 +01:00
|
|
|
. ./version.sh
|
|
|
|
|
2012-12-04 00:56:20 +01:00
|
|
|
corpus_size=large
|
|
|
|
|
|
|
|
while test "$#" -ne 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-d|--debug)
|
|
|
|
debug=t;
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-s|--small)
|
|
|
|
corpus_size=small;
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-m|--medium)
|
|
|
|
corpus_size=medium;
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-l|--large)
|
|
|
|
corpus_size=large;
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "error: unknown performance test option '$1'" >&2; exit 1 ;;
|
|
|
|
esac
|
|
|
|
done
|
2012-11-17 17:28:15 +01:00
|
|
|
. ../test/test-lib-common.sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if ! test -x ../notmuch
|
|
|
|
then
|
|
|
|
echo >&2 'You do not seem to have built notmuch yet.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-12-03 13:48:53 +01:00
|
|
|
DB_CACHE_DIR=${TEST_DIRECTORY}/notmuch.cache.$corpus_size
|
|
|
|
|
2012-11-17 17:28:15 +01:00
|
|
|
add_email_corpus ()
|
|
|
|
{
|
|
|
|
rm -rf ${MAIL_DIR}
|
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
CORPUS_DIR=${TEST_DIRECTORY}/corpus
|
|
|
|
mkdir -p "${CORPUS_DIR}"
|
2012-11-17 17:28:15 +01:00
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
MAIL_CORPUS="${CORPUS_DIR}/mail.${corpus_size}"
|
|
|
|
TAG_CORPUS="${CORPUS_DIR}/tags"
|
2012-12-04 03:59:56 +01:00
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
if command -v pixz > /dev/null; then
|
|
|
|
XZ=pixz
|
|
|
|
else
|
|
|
|
XZ=xz
|
2012-12-04 03:59:56 +01:00
|
|
|
fi
|
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
if [ ! -d "${CORPUS_DIR}/manifest" ]; then
|
|
|
|
|
|
|
|
printf "Unpacking manifests\n"
|
|
|
|
tar --extract --use-compress-program ${XZ} --strip-components=1 \
|
|
|
|
--directory ${TEST_DIRECTORY}/corpus \
|
|
|
|
--wildcards --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
|
|
|
|
'notmuch-email-corpus/manifest/*'
|
2012-11-17 17:28:15 +01:00
|
|
|
fi
|
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
file_list=$(mktemp file_listXXXXXX)
|
|
|
|
if [ ! -d "$TAG_CORPUS" ] ; then
|
|
|
|
echo "notmuch-email-corpus/tags" >> $file_list
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$MAIL_CORPUS" ] ; then
|
|
|
|
if [[ "$corpus_size" != "large" ]]; then
|
|
|
|
sed s,^,notmuch-email-corpus/, < \
|
|
|
|
${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
|
2012-12-03 13:13:31 +01:00
|
|
|
else
|
2013-12-01 04:00:03 +01:00
|
|
|
echo "notmuch-email-corpus/mail" >> $file_list
|
2012-12-03 13:13:31 +01:00
|
|
|
fi
|
2013-12-01 04:00:03 +01:00
|
|
|
fi
|
2012-12-03 13:13:31 +01:00
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
if [[ -s $file_list ]]; then
|
2012-12-03 13:13:31 +01:00
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
printf "Unpacking corpus\n"
|
2012-12-03 13:13:31 +01:00
|
|
|
tar --checkpoint=.5000 --extract --strip-components=1 \
|
|
|
|
--directory ${TEST_DIRECTORY}/corpus \
|
|
|
|
--use-compress-program ${XZ} \
|
|
|
|
--file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
|
2013-12-01 04:00:03 +01:00
|
|
|
--anchored --recursion \
|
|
|
|
--files-from $file_list
|
2012-12-03 13:13:31 +01:00
|
|
|
|
|
|
|
printf "\n"
|
2012-11-17 17:28:15 +01:00
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
if [[ ! -d ${MAIL_CORPUS} ]]; then
|
|
|
|
printf "creating link farm\n"
|
|
|
|
|
|
|
|
if [[ "$corpus_size" = large ]]; then
|
|
|
|
cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
|
|
|
|
else
|
|
|
|
while read -r file; do
|
|
|
|
tdir=${MAIL_CORPUS}/$(dirname $file)
|
|
|
|
mkdir -p $tdir
|
|
|
|
ln ${TEST_DIRECTORY}/corpus/$file $tdir
|
|
|
|
done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-12-03 13:13:31 +01:00
|
|
|
fi
|
|
|
|
|
2013-12-01 04:00:03 +01:00
|
|
|
rm $file_list
|
2012-12-04 03:59:56 +01:00
|
|
|
cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
|
2012-12-03 13:13:31 +01:00
|
|
|
cp -lr $MAIL_CORPUS $MAIL_DIR
|
2012-12-03 13:48:53 +01:00
|
|
|
}
|
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
notmuch_new_with_cache ()
|
|
|
|
{
|
2012-12-03 13:48:53 +01:00
|
|
|
if [ -d $DB_CACHE_DIR ]; then
|
|
|
|
cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
|
|
|
|
else
|
2012-12-16 13:33:17 +01:00
|
|
|
"$1" 'Initial notmuch new' "notmuch new"
|
2012-12-03 13:48:53 +01:00
|
|
|
cache_database
|
|
|
|
fi
|
2012-11-17 17:28:15 +01:00
|
|
|
}
|
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
time_start ()
|
|
|
|
{
|
|
|
|
add_email_corpus
|
|
|
|
|
|
|
|
print_header
|
|
|
|
|
|
|
|
notmuch_new_with_cache time_run
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_start ()
|
|
|
|
{
|
|
|
|
add_email_corpus
|
|
|
|
|
|
|
|
local timestamp=$(date +%Y%m%dT%H%M%S)
|
|
|
|
log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
|
|
|
|
mkdir -p ${log_dir}
|
|
|
|
|
|
|
|
notmuch_new_with_cache memory_run
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_run ()
|
|
|
|
{
|
|
|
|
test_count=$(($test_count+1))
|
|
|
|
|
|
|
|
log_file=$log_dir/$test_count.log
|
2012-12-26 17:29:45 +01:00
|
|
|
talloc_log=$log_dir/$test_count.talloc
|
2012-12-16 13:33:17 +01:00
|
|
|
|
|
|
|
printf "[ %d ]\t%s\n" $test_count "$1"
|
|
|
|
|
2012-12-26 17:29:45 +01:00
|
|
|
NOTMUCH_TALLOC_REPORT="$talloc_log" valgrind --leak-check=full --log-file="$log_file" $2
|
2012-12-16 13:33:17 +01:00
|
|
|
|
|
|
|
awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
|
|
|
|
echo
|
2012-12-26 17:29:45 +01:00
|
|
|
sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
|
|
|
|
echo
|
2012-12-16 13:33:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
memory_done ()
|
|
|
|
{
|
|
|
|
time_done
|
|
|
|
}
|
|
|
|
|
|
|
|
cache_database ()
|
|
|
|
{
|
2012-12-03 13:48:53 +01:00
|
|
|
if [ -d $MAIL_DIR/.notmuch ]; then
|
|
|
|
cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
|
|
|
|
else
|
|
|
|
echo "Warning: No database found to cache"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
uncache_database ()
|
|
|
|
{
|
2012-12-03 13:48:53 +01:00
|
|
|
rm -rf $DB_CACHE_DIR
|
|
|
|
}
|
2012-12-03 13:13:31 +01:00
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
print_header ()
|
|
|
|
{
|
|
|
|
printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
|
2012-11-17 17:28:15 +01:00
|
|
|
}
|
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
time_run ()
|
|
|
|
{
|
2012-12-06 02:41:44 +01:00
|
|
|
printf " %-22s" "$1"
|
2012-12-16 13:33:17 +01:00
|
|
|
test_count=$(($test_count+1))
|
2012-11-17 17:28:15 +01:00
|
|
|
if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
|
2012-12-04 03:51:14 +01:00
|
|
|
if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
|
2012-11-17 17:28:15 +01:00
|
|
|
test_failure=$(($test_failure + 1))
|
2012-12-06 02:37:29 +01:00
|
|
|
return 1
|
2012-11-17 17:28:15 +01:00
|
|
|
fi
|
2012-12-06 02:37:29 +01:00
|
|
|
return 0
|
2012-11-17 17:28:15 +01:00
|
|
|
}
|
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
time_done ()
|
|
|
|
{
|
2012-11-17 17:28:15 +01:00
|
|
|
if [ "$test_failure" = "0" ]; then
|
|
|
|
rm -rf "$remove_tmp"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
cd -P "$test" || error "Cannot setup test environment"
|
|
|
|
test_failure=0
|
2012-12-16 13:33:17 +01:00
|
|
|
test_count=0
|
2012-12-06 02:41:44 +01:00
|
|
|
|
2012-12-16 13:33:17 +01:00
|
|
|
printf "\n%-55s [%s %s]\n" \
|
|
|
|
"$(basename "$0"): Testing ${test_description:-notmuch performance}" \
|
|
|
|
"${PERFTEST_VERSION}" "${corpus_size}"
|