diff options
-rw-r--r-- | .gitmodules | 4 | ||||
-rw-r--r-- | Makefile.am | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | bootstrap | 92 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
m--------- | gdbm/master | 0 | ||||
m--------- | gdbm/newcache | 0 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/benchmark.mk.in | 7 | ||||
-rw-r--r-- | src/fetchkeys.c | 18 | ||||
-rw-r--r-- | src/gnuplot.m4 | 26 | ||||
-rw-r--r-- | src/master/Makefile.am | 2 | ||||
-rw-r--r-- | src/newcache/Makefile.am | 5 | ||||
-rwxr-xr-x | src/runtest | 21 |
13 files changed, 144 insertions, 42 deletions
diff --git a/.gitmodules b/.gitmodules index a4fd957..dfb9f90 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "gdbm/newcache"] - path = gdbm/newcache - url = git://git.gnu.org.ua/gdbm.git - branch = newcache [submodule "gdbm/master"] path = gdbm/master url = git://git.gnu.org.ua/gdbm.git diff --git a/Makefile.am b/Makefile.am index 2020e06..db9b75f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,20 +1,20 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = gdbm/master gdbm/newcache src +SUBDIRS = @USER_SUBDIRS@ src BENCHMARKDIR=benchmarks NUMSAMPLES=5 benchmark: @if test -z "$(NRECS)"; then \ echo "Please set NRECS"; \ exit 1; \ fi; \ if test -z "$(NKEYS)"; then \ echo "Please set NKEYS"; \ exit 1; \ fi; \ - DIRNAME="$(BENCHMARKDIR)/$(NRECS)-$(NKEYS)"; \ + DIRNAME="$(BENCHMARKDIR)/$(BENCHMARKPREFIX)$(NRECS)-$(NKEYS)"; \ if ! test -d "$$DIRNAME"; then \ mkdir -p $$DIRNAME; \ (echo "NRECS=$(NRECS)"; \ echo "NKEYS=$(NKEYS)"; \ echo "MAXCACHE=$(MAXCACHE)"; \ echo "NUMSAMPLES=$(NUMSAMPLES)"; \ diff --git a/bootstrap b/bootstrap index 1726aea..723788f 100644..100755 --- a/bootstrap +++ b/bootstrap @@ -1,8 +1,86 @@ #!/bin/sh -set e -test -d m4 || mkdir m4 -test -d gdbm || mkdir gdbm -git submodule init -git submodule update -git submodule foreach ./bootstrap -autoreconf -f -i -s +#! -*- perl -*- +eval 'exec perl -x -S $0 ${1+"$@"}' + if 0; + +use strict; +use warnings; +use File::Basename; + +my %target; + +die "no bootstrap.conf in current working directory\n" + unless -f "bootstrap.conf"; + +# Read configuration +open(my $fh, '<', 'bootstrap.conf') + or die "can't open bootstrap.conf: $!\n"; +my $i = 0; +while (<$fh>) { + chomp; + s/^\s+//; + s/#.*$//; + next if /^$/ ; + my ($treeish, $subdir) = split /\s+/; + if (!$subdir) { + $subdir = basename($treeish); + } + + if ($subdir ne "master") { + unless (-d "gdbm/$subdir") { + system("git -C gdbm clone -b $treeish ./master $subdir"); + } + } + system("(cd gdbm/$subdir; ./bootstrap)"); + + unless (-d "src/$subdir") { + mkdir "src/$subdir" + } + my $makefile = "src/$subdir/Makefile.am"; + unless (-f $makefile) { + open(my $of, '>', $makefile) + or die "can't open $makefile for writing: $!\n"; + print $of <<EOT; +noinst_PROGRAMS=fetchkeys +fetchkeys_SOURCES=fetchkeys.c +VPATH=\$(top_srcdir)/src +LDADD=../../gdbm/$subdir/src/.libs/libgdbm.a +AM_CPPFLAGS=-DSIZEOF_OFF_T=8 -I\$(top_srcdir)/gdbm/$subdir/src/ +EOT + ; + close $of; + } + $target{$subdir} = { + order => $i, + treeish => $treeish + }; + ++$i; +} +close($fh); + +# +# Creating directories +# +unless (-d 'm4') { + mkdir 'm4' +} +unless (-d 'gdbm') { + mkdir 'gdbm' +} + +system("git submodule init"); +system("git submodule update"); + +# +# Creating bootstrap.mk +# +my @k = sort { $target{$a}{order} <=> $target{$b}{order}} keys %target; +my $gdbm_subdirs = join(' ', map { "gdbm/$_" } @k); +open($fh, '>', 'bootstrap.mk') + or die "can't open bootstrap.mk: $!\n"; +print $fh "AC_SUBST([USER_SUBDIRS],['$gdbm_subdirs'])\n"; +print $fh "AC_SUBST([USER_TARGETS],['" . join(' ', @k) . "'])\n"; +print $fh "AC_CONFIG_SUBDIRS([$gdbm_subdirs])\n"; +print $fh "AC_CONFIG_FILES([" . join(' ', map { "src/$_/Makefile" } @k) . "])\n"; +close $fh; + diff --git a/configure.ac b/configure.ac index 84f1957..3d7dcb7 100644 --- a/configure.ac +++ b/configure.ac @@ -5,14 +5,11 @@ AC_INIT([cache-benchmarks],[0.1],[gray@gnu.org], AC_CONFIG_SRCDIR([src/fetchkeys.c]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([-Wall -Werror 1.11.5 foreign tar-ustar silent-rules]) # Checks for programs. AC_PROG_CC - -AC_CONFIG_SUBDIRS(gdbm/master gdbm/newcache) +m4_include([bootstrap.mk]) AC_CONFIG_FILES([Makefile src/Makefile - src/master/Makefile - src/newcache/Makefile src/benchmark.mk]) AC_OUTPUT diff --git a/gdbm/master b/gdbm/master -Subproject c0acf4aa6eefcf5b90f25416d64f8c6090363a8 +Subproject 2cb3428f11998e6f10a92a3963c245cbc8ed7cf diff --git a/gdbm/newcache b/gdbm/newcache deleted file mode 160000 -Subproject e818549f764b79cd773135d52e5740d5c5064da diff --git a/src/Makefile.am b/src/Makefile.am index c019df3..0e1b1b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS=newcache master +SUBDIRS=@USER_TARGETS@ EXTRA_DIST=fechkeys.c runtest gnuplot.m4 benchmark.mk.in diff --git a/src/benchmark.mk.in b/src/benchmark.mk.in index 43c605c..4b4f199 100644 --- a/src/benchmark.mk.in +++ b/src/benchmark.mk.in @@ -15,36 +15,39 @@ am__v_at_1 = abs_top_srcdir = @abs_top_srcdir@ abs_top_builddir = @abs_top_builddir@ MASTERDIR=$(abs_top_builddir)/gdbm/master GDBMTOOL=$(MASTERDIR)/src/gdbmtool TESTDIR=$(MASTERDIR)/tests +USER_TARGETS=@USER_TARGETS@ +LOGS=$(patsubst %, %.log, $(USER_TARGETS)) all: test -test: master.log newcache.log +test: $(LOGS) %.log: keys.txt a.gdbm $(AM_V_GEN)MAXCACHE=$(MAXCACHE); \ $(abs_top_srcdir)/src/runtest -n $(NUMSAMPLES) $(RUNTESTOPT) \ --final $${MAXCACHE:-$$(($$($(GDBMTOOL) a.gdbm dir |\ sed -n -e '2{' \ -e 's/.*Buckets = //' \ -e 's/\.$$//' \ -e 'p}') + 100))} \ --log-file=$*.log \ $(abs_top_builddir)/src/$*/fetchkeys $(FETCHKEYSOPT) clean: - rm -f master.log newcache.log + rm -f $(LOGS) allclean: clean rm -f keys.txt a.gdbm keys.txt: @$(MAKE) -C $(TESTDIR) num2word $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | \ cut -f1 | shuf | head -n $(NKEYS) > keys.txt a.gdbm: @$(MAKE) -C $(TESTDIR) num2word gtload $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | $(TESTDIR)/gtload -clear a.gdbm benchmark.gnuplot: $(abs_top_srcdir)/src/gnuplot.m4 m4 -DNRECS=$(NRECS) -DNKEYS=$(NKEYS) -DNUMSAMPLES=$(NUMSAMPLES) \ + "-DTARGETS=$$(echo "@USER_TARGETS@" | sed -r 's/[[:space:]]+/,/g')" \ $(abs_top_srcdir)/src/gnuplot.m4 > benchmark.gnuplot plot: test benchmark.gnuplot gnuplot -p benchmark.gnuplot diff --git a/src/fetchkeys.c b/src/fetchkeys.c index 694f4d9..cfc0371 100644 --- a/src/fetchkeys.c +++ b/src/fetchkeys.c @@ -196,13 +196,13 @@ main (int argc, char **argv) unsigned long maxsize = 0; int flags = 0; struct timeval t_start, t_open, t_now, td; char *keystr; int b_opt = 0; - while ((i = getopt (argc, argv, "bc:t:nTpv")) != EOF) + while ((i = getopt (argc, argv, "bc:t:nTpVv")) != EOF) { switch (i) { case 'b': b_opt = 1; break; @@ -224,12 +224,28 @@ main (int argc, char **argv) break; case 'v': verbose = 1; break; + case 'V': + printf ("gdbm header version: %d.%d", + GDBM_VERSION_MAJOR, GDBM_VERSION_MINOR); +#ifdef GDBM_VERSION_PATCH +#if GDBM_VERSION_PATCH > 0 + printf (".%d", GDBM_VERSION_PATCH); +# endif +#endif + putchar ('\n'); + printf ("gdbm library version: %d.%d", + gdbm_version_number[0], gdbm_version_number[1]); + if (gdbm_version_number[2]) + printf (".%d", gdbm_version_number[2]); + putchar ('\n'); + exit (0); + default: exit (1); } } argc -= optind; diff --git a/src/gnuplot.m4 b/src/gnuplot.m4 index edee22e..411b86e 100644 --- a/src/gnuplot.m4 +++ b/src/gnuplot.m4 @@ -1,25 +1,25 @@ divert(-1) -changequote([.]) +changequote([,]) +define([_PLOT], +["$2.log" \ + using 1:8:9:10 \ + title "GDBM $2" with errorbars ls $1, \ + "" using 1:8 \ + notitle \ + smooth bezier ls $1[]dnl +ifelse([$3],,,[dnl +,\ + $0(eval(($1 % 3) + 1), shift(shift($*)))])]) +define([PLOT],[plot _PLOT(1, $*)]) divert(0)dnl set title "Execution time as function of cache size.\n\ Database size NRECS entries. Key set size NKEYS.\n\ Each measurement averages NUMSAMPLES samples." set xlabel 'Cache entries' set ylabel 'Runtime (seconds)' set style line 1 linecolor rgb "dark-red" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 set style line 2 linecolor rgb "#e69f00" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 set style line 3 linecolor rgb "blue" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 set style line 4 linecolor rgb "#0072b2" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 -plot "master.log" \ - using 1:8:9:10 \ - title "GDBM 1.18.1" with errorbars ls 1, \ - "" using 1:8 \ - notitle \ - smooth bezier ls 2, \ - "newcache.log" \ - using 1:8:9:10 \ - title "GDBM newcache" with errorbars ls 3, \ - "" using 1:8 \ - notitle \ - smooth bezier ls 4 +PLOT(TARGETS) diff --git a/src/master/Makefile.am b/src/master/Makefile.am index c3adae5..8807411 100644 --- a/src/master/Makefile.am +++ b/src/master/Makefile.am @@ -1,5 +1,5 @@ noinst_PROGRAMS=fetchkeys fetchkeys_SOURCES=fetchkeys.c VPATH=$(top_srcdir)/src LDADD=../../gdbm/master/src/.libs/libgdbm.a -AM_CPPFLAGS=-I$(top_srcdir)/gdbm/master/src/ +AM_CPPFLAGS=-DSIZEOF_OFF_T=8 -I$(top_srcdir)/gdbm/master/src/ diff --git a/src/newcache/Makefile.am b/src/newcache/Makefile.am deleted file mode 100644 index a916d36..0000000 --- a/src/newcache/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -noinst_PROGRAMS=fetchkeys -fetchkeys_SOURCES=fetchkeys.c -VPATH=$(top_srcdir)/src -LDADD=../../gdbm/newcache/src/.libs/libgdbm.a -AM_CPPFLAGS=-I$(top_srcdir)/gdbm/newcache/src/ diff --git a/src/runtest b/src/runtest index e11f7c7..0840e10 100755 --- a/src/runtest +++ b/src/runtest @@ -12,12 +12,13 @@ use File::Spec; my $nsamples = 1; # Number of times to run each test. my $c_init = 1; # Initial cache capacity. my $c_step = 100; # Cache capacity increment. my $c_final = 100; # Final cache capacity. my $drop_caches; # Drop system disk caches before each run. my $log_file; # Name of the log file. +my $c_pow2; # Select power of 2 cache sizes use constant { AVG => 0, MIN => 1, MAX => 2 }; @@ -41,12 +42,14 @@ sub runtest { TOTAL => 0, OPEN => 1, LOOP => 2 }; my @times = ([0,100,0],[0,100,0],[0,100,0]); +#print "run ".join(' ',@_)."\n"; +#exit; my $n; for ($n = 0; $n < $nsamples; $n++) { if ($drop_caches) { system($drop_caches); } open(PH, '-|', @_) @@ -80,12 +83,13 @@ sub runtest { GetOptions( 'n=n' => \$nsamples, 'init|i=n' => \$c_init, 'step|s=n' => \$c_step, 'final|end|e=n' => \$c_final, + '2' => \$c_pow2, 'drop-caches|d' => sub { $drop_caches = File::Spec->catfile(dirname($0), 'dropcache'); unless (-x $drop_caches) { print STDERR <<EOT; $0: the option --drop-caches (-d) requires that the program $drop_caches be built, owned by root, and have the setuid bit set (or the tests be @@ -105,21 +109,34 @@ if ($c_init > $c_final) { $c_init = 10; } if ($c_step > $c_final - $c_init) { $c_step = 1; } +if ($c_pow2) { + $c_init = int(log($c_init) / log(2)); + if ($c_init < 2) { + $c_init = 2; + } + my $f2 = int(log($c_final) / log(2)); + if ((1 << $f2) < $c_final) { + $f2++; + } + $c_step = 1; +} + if ($log_file) { open(LOG, '>', $log_file) or die "can't open log file $log_file: $!"; } else { open(LOG, '>&', 'STDOUT') or die "can't dup STDOUT: $!"; } for (my $c = $c_init; $c <= $c_final; $c += $c_step) { - printf LOG "%d ", $c; - foreach my $t (runtest(@ARGV, '-c', $c)) { + my $size = $c_pow2 ? (1 << $c) : $c; + printf LOG "%d ", $size; + foreach my $t (runtest(@ARGV, '-c', $size)) { printf LOG " %.6f", $t; } print LOG "\n"; } |