diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-11-14 12:27:26 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-11-14 15:21:58 +0000 |
commit | 092a6808cdb3235c3565a86ada764bf3c3e909da (patch) | |
tree | de861cdc2e10c2c7d9a67f6dddbc820835611473 | |
parent | 89c1dd283afb0d8c3bc4904f9ee2af9573f73828 (diff) | |
download | cache-benchmarks-master.tar.gz cache-benchmarks-master.tar.bz2 |
-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,5 +1,5 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = gdbm/master gdbm/newcache src +SUBDIRS = @USER_SUBDIRS@ src BENCHMARKDIR=benchmarks NUMSAMPLES=5 benchmark: @@ -11,7 +11,7 @@ benchmark: 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)"; \ 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 @@ -8,11 +8,8 @@ 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 2dc9267a91a98733a18ebb3b8488da8016539f8 +Subproject 2cb3428f11998e6f10a92a3963c245cbc8ed7cf diff --git a/gdbm/newcache b/gdbm/newcache deleted file mode 160000 -Subproject 35d6474da608623482a95e89fae79420ec7eeb1 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 @@ -18,9 +18,11 @@ 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) \ @@ -32,7 +34,7 @@ test: master.log newcache.log --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: @@ -44,6 +46,7 @@ a.gdbm: $(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 @@ -199,7 +199,7 @@ main (int argc, char **argv) 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) { @@ -227,6 +227,22 @@ main (int argc, char **argv) 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); } diff --git a/src/gnuplot.m4 b/src/gnuplot.m4 index edee22e..411b86e 100644 --- a/src/gnuplot.m4 +++ b/src/gnuplot.m4 @@ -1,5 +1,16 @@ 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\ @@ -11,15 +22,4 @@ set style line 2 linecolor rgb "#e69f00" linewidth 1.000 dashtype solid pointtyp 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 @@ -2,4 +2,4 @@ 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 @@ -15,6 +15,7 @@ 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, @@ -44,6 +45,8 @@ sub runtest { }; 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) { @@ -83,6 +86,7 @@ GetOptions( '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) { @@ -108,6 +112,18 @@ 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 { @@ -115,8 +131,9 @@ if ($log_file) { } 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"; |