Commit c0ddd00b authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Hacking makefiles. Also make the filenames used by the tests work more reliably. Addresses #782.

git-svn-id: file:///svn/tokudb@3792 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0d00eb5d
Branches unavailable
Tags unavailable
No related merge requests found
# ROOT is the the name of the root of the tokudb make directory heirarchy, starting at the cwd
ROOT =
default: build
VGRIND = valgrind
OPTFLAGS = -O3
CFLAGS = $(OPTFLAGS) -Wall -W -Wcast-align -Wbad-function-cast -Wextra -Wmissing-noreturn -Wmissing-format-attribute -g3 -ggdb3 -Werror -fPIC -Wshadow -fvisibility=hidden
CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500
LDFLAGS = -lz
DIRS = newbrt
# src cxx utils db-benchmark-test db-benchmark-test-cxx
include $(patsubst %,%/Makefile.include,$(DIRS))
build: $(BINS)
check: $(CHECKS)
ifeq ($(VERBOSE),2)
VERBVERBOSE=-v
MAYBEATSIGN=
else
ifeq ($(VERBOSE),1)
VERBVERBOSE=-q
MAYBEATSIGN=
else
VERBVERBOSE=-q
MAYBEATSIGN=@
endif
endif
ifeq ($(CYGWIN),cygwin)
else
FPICFLAGS = -fPIC
# valgrind is not present on cygwin
VGRIND = valgrind --quiet --error-exitcode=1 --leak-check=yes
endif
%.check: %
$(VGRIND) ./$< $(VERBVERBOSE)
......@@ -32,7 +32,7 @@ endif
CFLAGS = -Wall -W -Wcast-align -Wbad-function-cast -Wextra -Wmissing-noreturn -Wmissing-format-attribute $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS) $(PROF_FLAGS) -Werror $(FPICFLAGS) -Wshadow -fvisibility=hidden
LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS)
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500
leafentry.o: CFLAGS+=-Wconversion
......@@ -85,8 +85,6 @@ REGRESSION_TESTS = \
BINS = $(REGRESSION_TESTS) \
benchmark-test \
brtdump \
randbrt \
randdb4 \
tdb_logprint \
# This line intentially kept commented so I can have a \ on the end of the previous line
......@@ -95,6 +93,7 @@ OFILES = \
brt-verify.o \
brt.o \
cachetable.o \
crc.o \
fifo.o \
fingerprint.o \
key.o \
......@@ -172,7 +171,7 @@ HFILES = $(wildcard *.h)
BRT_INTERNAL_H_INCLUDES = brt-internal.h cachetable.h fifo.h omt.h brt.h brt-search.h brttypes.h yerror.h ybt.h log.h ../include/db.h kv-pair.h memory.h crc.h mempool.h leafentry.h
key.o: brttypes.h key.h
list-test: list-test.o toku_assert.o
test-brt-delete-both: ybt.o brt.o fifo.o omt.o memory.o leafentry.o brt-serialize.o cachetable.o ybt.o key.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o
test-brt-delete-both: $(OFILES)
test-inc-split: $(TEST_OFILES)
brt-test-helpers.o: $(BRT_INTERNAL_H_INCLUDES) toku_assert.h
test-del-inorder: $(TEST_OFILES)
......@@ -181,7 +180,7 @@ ybt.o: ybt.h brttypes.h ../include/db.h
ybt-test: ybt-test.o ybt.o memory.o toku_assert.o
ybt-test.o: ybt.h ../include/db.h
cachetable.o: brttypes.h cachetable.h hashfun.h memory.h primes.h toku_assert.h $(BRT_INTERNAL_H_INCLUDES) log_header.h
brt-test0 brt-test1 brt-test2 brt-test3 brt-test4 brt-test5 test-brt-overflow brt-test-named-db brt-test-cursor brt-test-cursor-2 brt-test: ybt.o brt.o fifo.o omt.o leafentry.o memory.o brt-serialize.o cachetable.o ybt.o key.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o
brt-test0 brt-test1 brt-test2 brt-test3 brt-test4 brt-test5 test-brt-overflow brt-test-named-db brt-test-cursor brt-test-cursor-2 brt-test: $(OFILES)
log.o: log_header.h log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES)
logformat: logformat.o toku_assert.o
brt-test0.o brt-test1.o brt-test2.o brt-test3.o brt-test4.o brt-test5.o test-brt-overflow.h brt-test-named-db.o brt-test-cursor.o brt-test-cursor-2.o brt-test.o brt.o: brt.h brt-search.h ../include/db.h fifo.h omt.h brttypes.h cachetable.h memory.h $(BRT_INTERNAL_H_INCLUDES)
......@@ -194,7 +193,7 @@ fifo-test: fifo.o memory.o toku_assert.o ybt.o
brt-serialize.o: $(BRT_INTERNAL_H_INCLUDES) key.h wbuf.h rbuf.h
brt-bigtest: memory.o ybt.o brt.o omt.o cachetable.o key.o fifo.o brt-serialize.o
brt-bigtest.o: brt.h brt-search.h ../include/db.h
log-test6 log-test5 log-test4 log-test3 log-test2 log-test: log.o memory.o leafentry.o toku_assert.o roll.o log_code.o brt-serialize.o brt.o cachetable.o omt.o ybt.o fifo.o key.o fingerprint.o brt-verify.o mempool.o primes.o
log-test6 log-test5 log-test4 log-test3 log-test2 log-test: $(OFILES)
brt-verify.o: $(BRT_INTERNAL_H_INCLUDES)
fingerprint.o: $(BRT_INTERNAL_H_INCLUDES)
mempool.o: toku_assert.h mempool.h
......@@ -203,7 +202,7 @@ toku_assert.o: toku_assert.h
omt-test.o: toku_assert.h memory.h toku_assert.h ../include/db.h brttypes.h
omt-test: omt-test.o omt.o memory.o toku_assert.o
brt-serialize-test: brt-serialize-test.o brt-serialize.o leafentry.o memory.o fifo.o omt.o key.o ybt.o brt.o cachetable.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o
brt-serialize-test: $(OFILES) brt-serialize-test.o
test_toku_malloc_plain_free: memory.o toku_assert.o
......@@ -236,10 +235,6 @@ clean:
rm -rf $(BINS) *.o *.bb *.bbg *.da *.gcov *.gcno *.gcda
rm -rf test_oexcl.c.tmp *.brt
randdb4: LOADLIBES=-ldb
randdb4: randdb4.o toku_assert.o
randbrt: brt.o fifo.o cachetable.o memory.o brt-serialize.o
# After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences.
testdump: brtdump
./brtdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./brtdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.o && diff dump.o dump.r
......
......@@ -8,7 +8,7 @@
#include "fifo.h"
#include "yerror.h"
#include "brt.h"
#include "crc.h"
#include "crc.h"
#include "list.h"
#include "mempool.h"
#include "kv-pair.h"
......@@ -225,6 +225,8 @@ void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size);
void toku_verify_all_in_mempool(BRTNODE node);
int toku_verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, bytevec hirange, ITEMLEN hilen, int recurse) ;
// Diff from 5 to 6: Added leafentry_estimate
#define BRT_LAYOUT_VERSION 6
......
......@@ -15,7 +15,7 @@ static void test_serialize(void) {
// struct brt source_brt;
int nodesize = 1024;
struct brtnode sn, *dn;
int fd = open("brt-serialize-test.brt", O_RDWR|O_CREAT, 0777);
int fd = open(__FILE__ "brt", O_RDWR|O_CREAT, 0777);
int r;
const u_int32_t randval = random();
assert(fd>=0);
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#define _XOPEN_SOURCE 500
#include "toku_assert.h"
#include "brt-internal.h"
#include "key.h"
......@@ -680,7 +678,7 @@ int read_char (int fd, off_t *at, char *result) {
}
int read_uint64_t (int fd, off_t *at, u_int64_t *result) {
u_int32_t v1,v2;
u_int32_t v1=0,v2=0;
int r;
if ((r = read_int(fd, at, &v1))) return r;
if ((r = read_int(fd, at, &v2))) return r;
......@@ -704,14 +702,14 @@ int toku_deserialize_fifo_at (int fd, off_t at, FIFO *fifo) {
FIFO result;
int r = toku_fifo_create(&result);
if (r) return r;
u_int32_t count;
u_int32_t count=0;
if ((r=read_int(fd, &at, &count))) return r;
u_int32_t i;
for (i=0; i<count; i++) {
char type;
TXNID xid;
u_int32_t keylen, vallen;
char *key, *val;
u_int32_t keylen=0, vallen=0;
char *key=0, *val=0;
if ((r=read_char(fd, &at, &type))) return r;
if ((r=read_uint64_t(fd, &at, &xid))) return r;
if ((r=read_int(fd, &at, &keylen))) return r;
......
......@@ -29,7 +29,7 @@ static int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT
}
static void assert_cursor_notfound(BRT brt, int position) {
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int r;
DBT kbt, vbt;
......@@ -46,7 +46,7 @@ static void assert_cursor_notfound(BRT brt, int position) {
}
static void assert_cursor_value(BRT brt, int position, long long value) {
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int r;
DBT kbt, vbt;
long long v;
......@@ -72,7 +72,7 @@ static void assert_cursor_value(BRT brt, int position, long long value) {
}
static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv) {
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int r;
DBT kbt, vbt;
long long v;
......@@ -280,7 +280,7 @@ static void test_brt_cursor_rfirst(int n, DB *db) {
}
static void assert_cursor_walk(BRT brt, int n) {
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int i;
int r;
......@@ -352,7 +352,7 @@ static void test_brt_cursor_walk(int n, DB *db) {
}
static void assert_cursor_rwalk(BRT brt, int n) {
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int i;
int r;
......@@ -424,7 +424,7 @@ static void test_brt_cursor_rwalk(int n, DB *db) {
}
static void assert_cursor_walk_inorder(BRT brt, int n) {
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int i;
int r;
char *prevkey;
......@@ -513,7 +513,7 @@ static void test_brt_cursor_rand(int n, DB *db) {
static void test_brt_cursor_split(int n, DB *db) {
CACHETABLE ct;
BRT brt;
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
int r;
int keyseqnum;
int i;
......@@ -726,7 +726,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
int r;
CACHETABLE ct;
BRT brt;
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
unlink(fname);
......@@ -798,7 +798,7 @@ static void test_brt_cursor_set_range(int n, DB *db) {
int r;
CACHETABLE ct;
BRT brt;
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
unlink(fname);
......@@ -864,7 +864,7 @@ static void test_brt_cursor_delete(int n, DB *db) {
int error;
CACHETABLE ct;
BRT brt;
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
unlink(fname);
......@@ -925,7 +925,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
int error;
CACHETABLE ct;
BRT brt;
BRT_CURSOR cursor;
BRT_CURSOR cursor=0;
unlink(fname);
......
......@@ -11,7 +11,7 @@ static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
static void test_named_db (void) {
const char *n0 = "brt-test-named-db-0.brt";
const char *n0 = __FILE__ "0.brt";
CACHETABLE ct;
BRT t0;
int r;
......
This diff is collapsed.
......@@ -14,7 +14,7 @@ static void test0 (void) {
BRT t;
int r;
CACHETABLE ct;
char fname[]="brt-test0.brt";
char fname[]= __FILE__ "0.brt";
if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__);
toku_memory_check=1;
toku_memory_check_all_free();
......
......@@ -14,7 +14,7 @@ static void test1 (void) {
BRT t;
int r;
CACHETABLE ct;
char fname[]="brt-test1.brt";
char fname[]= __FILE__ "1.brt";
DBT k,v;
toku_memory_check=1;
toku_memory_check_all_free();
......
......@@ -15,7 +15,7 @@ static void test2 (int memcheck, int limit) {
int r;
int i;
CACHETABLE ct;
char fname[]="brt-test2.brt";
char fname[]= __FILE__ "2.brt";
toku_memory_check=memcheck;
if (verbose) printf("%s:%d checking\n", __FILE__, __LINE__);
toku_memory_check_all_free();
......
......@@ -19,7 +19,7 @@ static void test5 (void) {
int *values;
int i;
CACHETABLE ct;
char fname[]="testbrt.brt";
char fname[]= __FILE__ ".brt";
toku_memory_check_all_free();
MALLOC_N(limit,values);
for (i=0; i<limit; i++) values[i]=-1;
......
......@@ -434,7 +434,7 @@ static int brtleaf_split (TOKULOGGER logger, FILENUM filenum, BRT t, BRTNODE nod
toku_omt_destroy(&old_omt);
LSN lsn;
LSN lsn={0};
r = toku_log_leafsplit(logger, &lsn, 0, filenum, node->thisnodename, B->thisnodename, n_leafentries, break_at, node->nodesize, B->rand4fingerprint, (t->flags&TOKU_DB_DUPSORT)!=0);
if (logger) {
node->log_lsn = lsn;
......@@ -1364,8 +1364,8 @@ int should_compare_both_keys (BRTNODE node, BRT_CMD cmd) {
static int brt_leaf_apply_cmd_once (BRT t, BRTNODE node, BRT_CMD cmd, TOKULOGGER logger,
u_int32_t idx, LEAFENTRY le) {
FILENUM filenum = toku_cachefile_filenum(t->cf);
u_int32_t newlen, newdisksize;
LEAFENTRY newdata;
u_int32_t newlen=0, newdisksize=0;
LEAFENTRY newdata=0;
int r = apply_cmd_to_leaf(cmd, le, &newlen, &newdisksize, &newdata);
if (r!=0) return r;
if (newdata) assert(newdisksize == leafentry_disksize(newdata));
......@@ -2398,9 +2398,7 @@ int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
return r;
}
int toku_verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, bytevec hirange, ITEMLEN hilen, int recurse, BRTNODE parent_brtnode);
int toku_dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN lolen, bytevec hirange, ITEMLEN hilen, BRTNODE parent_brtnode) {
int toku_dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN lolen, bytevec hirange, ITEMLEN hilen) {
int result=0;
BRTNODE node;
void *node_v;
......@@ -2409,7 +2407,7 @@ int toku_dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN
assert(r==0);
printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
node=node_v;
result=toku_verify_brtnode(brt, off, lorange, lolen, hirange, hilen, 0, parent_brtnode);
result=toku_verify_brtnode(brt, off, lorange, lolen, hirange, hilen, 0);
printf("%*sNode=%p\n", depth, "", node);
if (node->height>0) {
printf("%*sNode %lld nodesize=%d height=%d n_children=%d n_bytes_in_buffers=%d keyrange=%s %s\n",
......@@ -2436,8 +2434,7 @@ int toku_dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN
(i==0) ? lorange : node->u.n.childkeys[i-1],
(i==0) ? lolen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i-1]),
(i==node->u.n.n_children-1) ? hirange : node->u.n.childkeys[i],
(i==node->u.n.n_children-1) ? hilen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i]),
node
(i==node->u.n.n_children-1) ? hilen : toku_brt_pivot_key_len(brt, node->u.n.childkeys[i])
);
}
}
......@@ -2463,7 +2460,7 @@ int toku_dump_brt (BRT brt) {
}
rootp = toku_calculate_root_offset_pointer(brt);
printf("split_count=%d\n", split_count);
if ((r = toku_dump_brtnode(brt, *rootp, 0, 0, 0, 0, 0, null_brtnode))) goto died0;
if ((r = toku_dump_brtnode(brt, *rootp, 0, 0, 0, 0, 0))) goto died0;
if ((r = toku_unpin_brt_header(brt))!=0) return r;
brt->h = prev_header;
return 0;
......
......@@ -80,7 +80,7 @@ static void test0 (void) {
CACHETABLE t;
CACHEFILE f;
int r;
char fname[] = "test.dat";
char fname[] = __FILE__ "test.dat";
r=toku_create_cachetable(&t, 5, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
......@@ -204,7 +204,7 @@ static void test_nested_pin (void) {
int i0, i1;
int r;
void *vv,*vv2;
char fname[] = "test_ct.dat";
char fname[] = __FILE__ "test_ct.dat";
r = toku_create_cachetable(&t, 1, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
......@@ -262,9 +262,9 @@ static int add222_fetch (CACHEFILE cf __attribute__((__unused__)), CACHEKEY key,
static void test_multi_filehandles (void) {
CACHETABLE t;
CACHEFILE f1,f2,f3;
char fname1[]="test_ct.dat";
char fname2[]="test2_ct.dat";
char fname3[]="test3_ct.dat";
char fname1[]= __FILE__ "test_ct.dat";
char fname2[]= __FILE__ "test2_ct.dat";
char fname3[]= __FILE__ "test3_ct.dat";
int r;
void *v;
unlink(fname1);
......@@ -318,7 +318,7 @@ static void test_dirty() {
r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER);
assert(r == 0);
char *fname = "test.dat";
char *fname = __FILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r == 0);
......@@ -426,7 +426,7 @@ static void test_size_resize() {
r = toku_create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER);
assert(r == 0);
char *fname = "test.dat";
char *fname = __FILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r == 0);
......@@ -477,7 +477,7 @@ static void test_size_flush() {
r = toku_create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER);
assert(r == 0);
char *fname = "test.dat";
char *fname = __FILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r == 0);
......@@ -567,7 +567,7 @@ static void test_rename (void) {
CACHEFILE f;
int i;
int r;
const char fname[] = "ct-test-rename.dat";
const char fname[] = __FILE__ "rename.dat";
r=toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
......
......@@ -109,7 +109,7 @@ static void test_chaining (void) {
long i, trial;
r = toku_create_cachetable(&ct, N_PRESENT_LIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<N_FILES; i++) {
r = snprintf(fname[i], FILENAME_LEN, "cachetabletest2.%ld.dat", i);
r = snprintf(fname[i], FILENAME_LEN, __FILE__ ".%ld.dat", i);
assert(r>0 && r<FILENAME_LEN);
unlink(fname[i]);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, 0777); assert(r==0);
......
#include <sys/types.h>
#include <zlib.h>
// hack: include crc.h below so we can deprecate the call to crc32
inline u_int32_t toku_crc32 (u_int32_t oldcrc32, const void *data, u_int32_t len) {
if (len==0) return oldcrc32;
else return crc32((unsigned long)oldcrc32, data, (uInt)len);
}
// Hack
#include "crc.h"
......@@ -3,13 +3,11 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include <sys/types.h>
#include <zlib.h>
// zlib crc32 has a bug: If len==0 then it should return oldcrc32, but crc32 returns 0.
static inline u_int32_t toku_crc32 (u_int32_t oldcrc32, const void *data, u_int32_t len) {
if (len==0) return oldcrc32;
else return crc32((unsigned long)oldcrc32, data, (uInt)len);
}
inline u_int32_t toku_crc32 (u_int32_t oldcrc32, const void *data, u_int32_t len);
static const u_int32_t toku_null_crc = 0;
......
......@@ -3,7 +3,7 @@
#include <errno.h>
#include <sys/types.h>
typedef struct value *OMTVALUE;
typedef void *OMTVALUE;
#include "omt.h"
#include "../newbrt/memory.h"
#include "../newbrt/toku_assert.h"
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
/* Test random insertions using db4 */
#include "toku_assert.h"
#include <db.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <string.h>
#include <limits.h>
enum { MAX_PATHNAME_LEN = 100 };
const char dir[]="db4dir";
DB_ENV *env=0;
DB *db=0;
#if DB_VERSION_MINOR == 0
#define IF40(x,y) x
#else
#define IF40(x,y) y
#endif
void create_directory (void) {
char command[MAX_PATHNAME_LEN];
int r;
r=snprintf(command, MAX_PATHNAME_LEN, "rm -rf %s", dir);
assert(r<MAX_PATHNAME_LEN);
system(command);
r=mkdir(dir, 0777);
assert(r==0);
r=db_env_create(&env, 0);
assert(r==0);
r=env->set_cachesize(env, 0, 512*(1<<20), 0);
assert(r==0);
#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 3
IF40((void)0,
({
unsigned int gbytes,bytes;
int ncaches;
r=env->get_cachesize(env, &gbytes, &bytes, &ncaches);
assert(r==0);
printf("Using %.2fMiB Berkeley DB Cache Size\n", gbytes*1024 + ((double)bytes/(1<<20)));
}));
#endif
r= env->open(env, dir, DB_CREATE|DB_INIT_MPOOL,0777); // No logging.
assert(r==0);
r=db_create(&db, env, 0);
assert(r==0);
IF40(
r=db->open(db, "files", 0, DB_BTREE, DB_CREATE, 0777),
r=db->open(db, 0, "files", 0, DB_BTREE, DB_CREATE, 0777));
assert(r==0);
}
int write_one (long int n1, long int n2) {
char keystring[100],valstring[100];
int keysize;
int datasize;
DB_TXN *txn=0;
DBT key,data;
int r;
keysize = snprintf(keystring, 100, "%08lx%08lx", n1, n2);
datasize = snprintf(valstring, 100, "%ld %ld %ld %ld %ld %ld", n1, n2, (long)(random()), (long)(random()), (long)(random()), (long)(random()));
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
key.data = keystring;
key.size = keysize;
data.data = valstring;
data.size = datasize;
r = db->put(db, txn, &key, &data, 0);
assert(r==0);
return keysize+datasize;
}
/* Write a sequence evenly spaced. */
long long write_sequence (int n_inserts) {
unsigned int step = UINT_MAX/n_inserts;
int i,j;
long long n_bytes=0;
printf("%d inserts, step %d\n", n_inserts, step);
for (i=0,j=0; i<n_inserts; i++,j+=step) {
n_bytes+=write_one(j, random());
}
return n_bytes;
}
long long write_random (int n_inserts) {
int i;
long long n_bytes=0;
for (i=0; i<n_inserts; i++) {
n_bytes+=write_one(random(), random());
}
return n_bytes;
}
double tdiff (struct timeval *t1, struct timeval *t0) {
return (t1->tv_sec-t0->tv_sec)+1e-6*(t1->tv_usec-t0->tv_usec);
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
int n_s_inserts=200000000;
int n_inserts=50000;
struct timeval t0,t1,t00;
long long n_bytes;
int r;
create_directory();
gettimeofday(&t0, 0);
n_bytes=write_sequence(n_s_inserts);
gettimeofday(&t00, 0);
r=db->sync(db, 0); assert(r==0);
gettimeofday(&t1, 0);
{
double t = tdiff(&t1, &t0);
printf("%9d sequential inserts in %.3fs (%.3fs in sync), %.1f inserts/s. %lld bytes, %.1f bytes/s\n", n_s_inserts, t, tdiff(&t1,&t00), n_s_inserts/t, n_bytes, n_bytes/t);
}
gettimeofday(&t0, 0);
n_bytes=write_random(n_inserts);
gettimeofday(&t00, 0);
r=db->sync(db, 0); assert(r==0);
gettimeofday(&t1, 0);
{
double t = tdiff(&t1, &t0);
printf("%9d random inserts in %.3fs (%.3fs in sync), %.1f inserts/s. %lld bytes, %.1f bytes/s\n", n_inserts, t, tdiff(&t1, &t00), n_inserts/t, n_bytes, n_bytes/t);
}
gettimeofday(&t0, 0);
r=db->close(db,0); assert(r==0);
r=env->close(env,0); assert(r==0);
gettimeofday(&t1, 0);
printf("Time to close %.3fs\n", tdiff(&t1,&t0));
return 0;
}
......@@ -267,10 +267,10 @@ void toku_recover_brtdeq (LSN lsn, FILENUM filenum, DISKOFF diskoff, u_int32_t c
recover_setup_node(filenum, diskoff, &cf, &node);
assert(node->height>0);
//printf("deq: %lld expected_old_fingerprint=%08x actual=%08x new=%08x\n", diskoff, oldfingerprint, node->local_fingerprint, newfingerprint);
bytevec actual_key, actual_data;
ITEMLEN actual_keylen, actual_datalen;
u_int32_t actual_type;
TXNID actual_xid;
bytevec actual_key=0, actual_data=0;
ITEMLEN actual_keylen=0, actual_datalen=0;
u_int32_t actual_type=0;
TXNID actual_xid=0;
assert(childnum<(u_int32_t)node->u.n.n_children);
r = toku_fifo_peek(BNC_BUFFER(node, childnum), &actual_key, &actual_keylen, &actual_data, &actual_datalen, &actual_type, &actual_xid);
assert(r==0);
......@@ -430,7 +430,7 @@ void toku_recover_fopen (LSN UU(lsn), TXNID UU(txnid), BYTESTRING fname, FILENUM
CACHEFILE cf;
int fd = open(fixedfname, O_RDWR, 0);
assert(fd>=0);
BRT brt;
BRT brt=0;
int r = toku_brt_create(&brt);
assert(r==0);
brt->fname = fixedfname;
......
......@@ -73,7 +73,7 @@ ydbtrace.o tdbtrace.o: tdbtrace.h
ydbtrace.o: ydb.c
$(CC) $(CFLAGS) $(CPPFLAGS) -DTOKUTRACE -c -o $@ $<
DBBINS = ydb.o errors.o elocks.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/fifo.o ../newbrt/key.o ../newbrt/leafentry.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/omt.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o ../newbrt/roll.o ../newbrt/toku_assert.o ../newbrt/recover.o
DBBINS = ydb.o errors.o elocks.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/crc.o ../newbrt/fifo.o ../newbrt/key.o ../newbrt/leafentry.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/omt.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o ../newbrt/roll.o ../newbrt/toku_assert.o ../newbrt/recover.o
TDBBINS = tdbtrace.o $(patsubst ydb.o,ydbtrace.o,$(DBBINS))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment