]> mj.ucw.cz Git - libucw.git/commitdiff
Yet another sorter tuning utility.
authorMartin Mares <mj@ucw.cz>
Tue, 11 Sep 2007 12:07:42 +0000 (14:07 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 11 Sep 2007 12:07:42 +0000 (14:07 +0200)
debug/sorter/Makefile
debug/sorter/radix-tune-thresh.sh [new file with mode: 0644]

index 6a871c64da9c6c4376f8be90d06ce6f7bf720288..5a3e262eae27dd8741adee69785e370e594d5719 100644 (file)
@@ -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 (file)
index 0000000..1c75ed5
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash
+# An utility for tuning the Sherlock's radix sorter threshold
+# (c) 2007 Martin Mares <mj@ucw.cz>
+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