From: Martin Mares Date: Tue, 11 Sep 2007 12:07:42 +0000 (+0200) Subject: Yet another sorter tuning utility. X-Git-Tag: holmes-import~506^2~13^2~20 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d6097caa134867e0e95a1ed9770ef3788b3c61fa;p=libucw.git Yet another sorter tuning utility. --- diff --git a/debug/sorter/Makefile b/debug/sorter/Makefile index 6a871c64..5a3e262e 100644 --- a/debug/sorter/Makefile +++ b/debug/sorter/Makefile @@ -1,9 +1,10 @@ # Tests related to the new sorter DIRS+=debug/sorter -PROGS+=$(addprefix $(o)/debug/sorter/,retros radix-file-test radix-asio-test radix-tune-bits) +PROGS+=$(addprefix $(o)/debug/sorter/,retros radix-file-test radix-asio-test radix-tune-bits radix-tune-thresh) $(o)/debug/sorter/retros: $(o)/debug/sorter/retros.o $(LIBSH) $(o)/debug/sorter/radix-file-test: $(o)/debug/sorter/radix-file-test.o $(LIBSH) $(o)/debug/sorter/radix-asio-test: $(o)/debug/sorter/radix-asio-test.o $(LIBSH) $(o)/debug/sorter/radix-tune-bits: $(s)/debug/sorter/radix-tune-bits.sh +$(o)/debug/sorter/radix-tune-thresh: $(s)/debug/sorter/radix-tune-thresh.sh diff --git a/debug/sorter/radix-tune-thresh.sh b/debug/sorter/radix-tune-thresh.sh new file mode 100644 index 00000000..1c75ed58 --- /dev/null +++ b/debug/sorter/radix-tune-thresh.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# An utility for tuning the Sherlock's radix sorter threshold +# (c) 2007 Martin Mares +set -e +UCW_PROGNAME="$0" +. lib/libucw.sh + +# Path to Sherlock build directory +[ -n "$BUILD" ] || BUILD=.. +[ -f "$BUILD/lib/sorter/sorter.h" ] || die "BUILD does not point to Sherlock build directory" + +# Find out sort buffer size +parse-config 'Sorter{##SortBuffer}' +SORTBUF=$CF_Sorter_SortBuffer +[ "$SORTBUF" -gt 0 ] || die "Unable to determine SortBuffer" +log "Detected sort buffer size $SORTBUF" + +# Find out radix-sorter width +[ -f "$BUILD/obj/config.mk" ] || die "Sherlock source not configured" +WIDTH=`sed <$BUILD/obj/config.mk 's/^CONFIG_UCW_RADIX_SORTER_BITS=\(.*\)/\1/;t;d'` +[ -n "$WIDTH" ] || die "CONFIG_UCW_RADIX_SORTER_BITS not set (!?)" +log "Detected radix-sorter width $WIDTH" + +# Maximum size of the test -- should be slightly less than a half of SortBuffer +SIZE=$(($SORTBUF/2 - 8192)) + +# Which sort-test test we try +TEST="2" + +# Which thresholds we try +THRS="16" +T=$SIZE +while [ $T -gt 100 ] ; do + THRS="$THRS $T" + T=$(($T/2)) +done + +if true ; then + +rm -f tmp/radix-* +echo "sizes" >tmp/radix-sizes +while [ $SIZE -gt 262144 ] ; do + echo $SIZE >>tmp/radix-sizes + for T in $THRS ; do + log "Trying size $SIZE with threshold $T" + $BUILD/obj/lib/sorter/sort-test -SSorter.RadixThreshold=$T -s$SIZE -t$TEST -v 2>&1 | tee -a tmp/radix-$T + done + SIZE=$(($SIZE/2)) +done + +fi + +FILES=tmp/radix-sizes +for T in $THRS ; do + a=tmp/radix-$T + echo >$a.out $T + sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out + FILES="$FILES $a.out" +done + +log "These are the results:" +paste $FILES