From bb469c92034f656420944e5f7fb6476d052f12d5 Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Tue, 16 Apr 2013 23:57:57 -0400 Subject: [PATCH] start doing db-scan. [t:1904] git-svn-id: file:///svn/toku/tokudb@13646 c7de825b-a66e-492c-adef-691d508d4ae1 --- release/examples/README.examples | 48 ++++++++++++++++++++++++-- release/examples/db-insert/Makefile | 8 ++--- release/examples/db-insert/db-insert.c | 15 +++++--- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/release/examples/README.examples b/release/examples/README.examples index e3be513adef..4ad0976774d 100644 --- a/release/examples/README.examples +++ b/release/examples/README.examples @@ -1,4 +1,48 @@ -The db-insert program measures the insertion performance of a Tokutek Fractal Tree. +The examples includes a pair of programs that can be compiled to use either the Berkeley DB library or the Tokutek Fractal Tree index library. -The db-scan program scans all of the key value pairs of a Tokutek Fractal Tree that was built with the db-insert program. +Note: The file formats are different from TokuDB and Berkley DB. Thus +you cannot access a database created by Berkeley DB using the Tokutek +DB, or vice-versa. +db-insert is a program that inserts random key-value pairs into a database. + +To build it and run it (it's been tested on Fedora 10): +$ cd db-insert +$ make (Makes the binaries) +Run the insertion workload under TokuDB: +$ ./db-insert +Run the insertion workload under BDB: +$ ./db-insert-bdb + +Here is what the output looks like (this on a Thinkpad X61s laptop +running Fedora 10). BDB is a little faster for sequential insertions +(the first three columns), but much much slower for random insertions +(the next 3 coluns), so that TokuDB is faster on combined workload. + +$ ./db-insert +serial and random insertions of 1048576 per batch +serial 2.609965s 401759/s random 10.983798s 95466/s cumulative 13.593869s 154272/s +serial 3.053433s 343409/s random 12.008670s 87318/s cumulative 28.656115s 146367/s +serial 5.198312s 201715/s random 15.087426s 69500/s cumulative 48.954605s 128516/s +serial 6.096396s 171999/s random 13.550688s 77382/s cumulative 68.638321s 122215/s +Shutdown 4.025110s +Total time 72.677498s for 8388608 insertions = 115422/s +$ ./db-insert-bdb +serial and random insertions of 1048576 per batch +serial 2.623888s 399627/s random 8.770850s 119552/s cumulative 11.394805s 184045/s +serial 3.081946s 340232/s random 21.046589s 49822/s cumulative 35.523434s 118071/s +serial 14.160498s 74049/s random 497.117523s 2109/s cumulative 546.804504s 11506/s +serial 1.534212s 683462/s random 1128.525146s 929/s cumulative 1676.863892s 5003/s +Shutdown 195.879242s +Total time 1872.746582s for 8388608 insertions = 4479/s + +The files are smaller for TokuDB than BDB. + +$ ls -lh ../bench.tokudb/ +total 39M +-rwxrwxr-x 1 bradley bradley 39M 2009-07-28 15:36 bench.db +$ ls -lh ../bench.bdb/ +total 322M +-rw-r--r-- 1 bradley bradley 322M 2009-07-28 16:14 bench.db + +There isn't much documentation for the Tokutek Fractal Tree index library, but most of the API is like Berkeley DB's. diff --git a/release/examples/db-insert/Makefile b/release/examples/db-insert/Makefile index cfb934c7b81..b96cea8a999 100644 --- a/release/examples/db-insert/Makefile +++ b/release/examples/db-insert/Makefile @@ -1,9 +1,9 @@ -DIRSUF = db -CPPFLAGS = -I../include -DDIRSUF=$(DIRSUF) +default: db-insert db-insert-bdb +CPPFLAGS = -I../include LDFLAGS = -L../.. -lfractaltreeindex -Wl,-rpath,../.. - +db-insert-bdb: db-insert.c + cc -ldb db-insert.c -o db-insert-bdb -DBDB default: db-insert clean: rm -rf db-insert bench.$(DIRSUF) - diff --git a/release/examples/db-insert/db-insert.c b/release/examples/db-insert/db-insert.c index c86378471f8..2c9f0a91207 100644 --- a/release/examples/db-insert/db-insert.c +++ b/release/examples/db-insert/db-insert.c @@ -1,9 +1,16 @@ /* -*- mode: C; c-basic-offset: 4 -*- */ #ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved." -/* Insert a bunch of stuff */ -#include +// Define BDB if you want to compile this to use Berkeley DB +#ifdef BDB +#include +#define DIRSUF bdb +#else #include +#define DIRSUF tokudb +#endif + +#include #include #include #include @@ -78,7 +85,7 @@ static void do_prelock(DB* db, DB_TXN* txn) { #define STRINGIFY2(s) #s #define STRINGIFY(s) STRINGIFY2(s) -const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */ +const char *dbdir = "../bench." STRINGIFY(DIRSUF); char *dbfilename = "bench.db"; char *dbname; @@ -98,7 +105,7 @@ static void benchmark_setup (void) { system(unlink_cmd); if (strcmp(dbdir, ".") != 0) { - r = toku_os_mkdir(dbdir,S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); + r = mkdir(dbdir,S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); assert(r == 0); } }