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

Work on trace implementation. Addresses #701.

git-svn-id: file:///svn/tokudb@3437 c7de825b-a66e-492c-adef-691d508d4ae1
parent db89cbfd
......@@ -262,6 +262,8 @@ char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -278,6 +278,8 @@ char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -282,6 +282,8 @@ char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -282,6 +282,8 @@ char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -287,6 +287,8 @@ char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -313,6 +313,8 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
printf("const char *db_version(int*,int *,int *) %s;\n", VISIBLE);
printf("int log_compare (const DB_LSN*, const DB_LSN *) %s;\n", VISIBLE);
printf("int db_env_set_func_fsync (int (*)(int)) %s;\n", VISIBLE);
printf("int toku_set_trace_file (char *fname) %s;\n", VISIBLE);
printf("int toku_close_trace_file (void) %s;\n", VISIBLE);
printf("#if defined(__cplusplus)\n}\n#endif\n");
printf("#endif\n");
return 0;
......
......@@ -282,6 +282,8 @@ char *db_strerror(int) __attribute__((__visibility__("default")));
const char *db_version(int*,int *,int *) __attribute__((__visibility__("default")));
int log_compare (const DB_LSN*, const DB_LSN *) __attribute__((__visibility__("default")));
int db_env_set_func_fsync (int (*)(int)) __attribute__((__visibility__("default")));
int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")));
int toku_close_trace_file (void) __attribute__((__visibility__("default")));
#if defined(__cplusplus)
}
#endif
......
......@@ -2,6 +2,7 @@
# make OSX=OSX
LIBNAME=libtokudb
TLIBNAME=libtokudbtrace
EXPORTMAP = -Wl,--version-script=export.map
VISIBILITY = -fvisibility=hidden
......@@ -18,11 +19,13 @@ CFLAGS+= $(VISIBILITY) $(PROF_FLAGS)
ifneq ($(OSX),)
LIBRARY=$(LIBNAME).dylib
TLIBRARY=$(TLIBNAME).dylib
SHARED=-dynamiclib
RPATHNAME=-install_name @rpath/$(LIBRARY)
CFLAGS+=-fno-common
else
LIBRARY=$(LIBNAME).so
TLIBRARY=$(TLIBNAME).so
SHARED=-shared $(EXPORTMAP)
RPATHNAME=
endif
......@@ -30,15 +33,21 @@ endif
build:
cd range_tree;$(MAKE) build
cd lock_tree;$(MAKE) build
$(MAKE) $(LIBRARY) $(LIBNAME).a
$(MAKE) $(LIBRARY) $(LIBNAME).a $(TLIBNAME).a $(TLIBRARY)
cd tests;$(MAKE) build
if ! diff $(LIBNAME).a ../lib/$(LIBNAME).a >/dev/null 2>&1; then cp $(LIBNAME).a ../lib/; fi
if ! diff $(LIBRARY) ../lib/$(LIBRARY) > /dev/null 2>&1; then cp $(LIBRARY) ../lib/; fi
if ! diff $(TLIBNAME).a ../lib/$(TLIBNAME).a >/dev/null 2>&1; then cp $(TLIBNAME).a ../lib/; fi
if ! diff $(TLIBRARY) ../lib/$(TLIBRARY) > /dev/null 2>&1; then cp $(TLIBRARY) ../lib/; fi
local: $(LIBRARY) $(LIBNAME).a $(TLIBNAME).a $(TLIBRARY)
.PHONY: install
install: $(LIBRARY) $(LIBNAME).a
install: $(LIBRARY) $(LIBNAME).a $(TLIBRARY) $(TLIBNAME).a
cp $(LIBRARY) ../lib/
cp $(LIBNAME).a ../lib
cp $(TLIBRARY) ../lib/
cp $(TLIBNAME).a ../lib
check_globals: $(LIBRARY)
python tokuglobals.py $(LIBRARY)
......@@ -51,15 +60,20 @@ strip: $(LIBRARY)
strip $(LIBRARY)
clean:
rm -rf $(LIBRARY) $(LIBNAME).a *.o *.gcno *.gcda *.gcov
rm -rf $(LIBRARY) $(LIBNAME).a $(TLIBRARY) $(TLIBNAME).a *.o *.gcno *.gcda *.gcov
cd tests && $(MAKE) clean
cd lock_tree && $(MAKE) clean
cd range_tree && $(MAKE) clean
ydb.o: ../include/db.h ../newbrt/cachetable.h ../newbrt/brt.h ../newbrt/log.c
ydbtrace.o ydb.o: ../include/db.h ../newbrt/cachetable.h ../newbrt/brt.h ../newbrt/log.c
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/gpma.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))
RANGETREE_BINS = range_tree/rangetree.o range_tree/tokuredblack.o
LOCKTREE_BINS = lock_tree/locktree.o lock_tree/rth.o lock_tree/lth.o lock_tree/idlth.o lock_tree/db_id.o $(RANGETREE_BINS)
......@@ -71,3 +85,11 @@ $(LIBNAME).a: $(DBBINS) $(LOCKTREE_BINS)
$(AR) rv $@ $^
$(LIBNAME).a(ydb.o): ydb.o
$(TLIBRARY): $(TDBBINS) $(LOCKTREE_BINS)
cc $(CPPFLAGS) $^ $(SHARED) -o $@ $(CFLAGS) -lz $(RPATHNAME)
$(TLIBNAME).a: $(TDBBINS) $(LOCKTREE_BINS)
$(AR) rv $@ $^
$(TLIBNAME).a(ydbtrace.o): ydbtrace.o
......@@ -21,11 +21,11 @@ static pthread_mutex_t ydb_big_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
static pthread_mutex_t ydb_big_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
void toku_ydb_lock() {
void toku_ydb_lock(void) {
int r = pthread_mutex_lock(&ydb_big_lock); assert(r == 0);
}
void toku_ydb_unlock() {
void toku_ydb_unlock(void) {
int r = pthread_mutex_unlock(&ydb_big_lock); assert(r == 0);
}
......@@ -8,6 +8,8 @@
db_env_set_func_fsync;
toku_ydb_error_all_cases;
toku_set_trace_file;
toku_close_trace_file;
local: *;
};
......
......@@ -33,6 +33,7 @@ endif
endif
BDB_LDFLAGS += -lpthread
TDB_LOADLIBES = -L.. -ltokudb -Wl,-rpath,.. -lpthread
TDB_TRACELOADLIBES = -L.. -ltokudbtrace -Wl,-rpath,.. -lpthread
ifeq ($(VGRIND),)
BDB_SUPPRESSIONS =
......@@ -63,6 +64,9 @@ RUN_ALL_TESTS = $(RUN_TDB_TESTS) $(RUN_BDB_TESTS)
all build: $(ALL_TESTS)
#traces: test_env_open_flags.tdbt
traces: $(patsubst %.tdb,%.tdbt,$(TDB_TESTS))
foo:
echo RUN_TDB_TESTS: $(RUN_TDB_TESTS)
echo ALL_TESTS: $(ALL_TESTS)
......@@ -135,6 +139,8 @@ libs:
$(UNSETTOKUENV) cc -DENVDIR=\"dir.$<.bdb\" $(BDB_CPPFLAGS) -DUSE_BDB -DIS_TDB=0 $(CFLAGS) $< $(BDB_LDFLAGS) -ldb -o $@
%.tdb: %.c
$(SETTOKUENV) cc -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
%.tdbt: %.c
$(SETTOKUENV) cc -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_TRACELOADLIBES) $< -o $@
.PHONY: %.recover
TLRECOVER = 2 3 4 5 6 7 8 9 10
......
......@@ -72,3 +72,11 @@ int int_dbt_cmp(DB *db, const DBT *a, const DBT *b) {
}
typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL;
#ifdef USE_TDB
#define SET_TRACE_FILE(x) toku_set_trace_file(x)
#define CLOSE_TRACE_FILE(x) toku_close_trace_file()
#else
#define SET_TRACE_FILE(x) ((void)0)
#define CLOSE_TRACE_FILE(x) ((void)0)
#endif
......@@ -13,7 +13,6 @@
#include "test.h"
void test_env_open_flags(int env_open_flags, int expectr) {
if (verbose) printf("test_env_open_flags:%d\n", env_open_flags);
......@@ -38,6 +37,10 @@ int main(int argc, const char *argv[]) {
system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777);
#ifdef USE_TDB
toku_set_trace_file(ENVDIR "/trace.tktrace");
#endif
/* test flags */
test_env_open_flags(0, ENOENT);
#ifdef TOKUDB
......@@ -49,5 +52,9 @@ int main(int argc, const char *argv[]) {
test_env_open_flags(DB_PRIVATE+DB_RECOVER, EINVAL);
test_env_open_flags(DB_PRIVATE+DB_CREATE+DB_INIT_MPOOL+DB_RECOVER, EINVAL);
#ifdef USE_TDB
toku_close_trace_file();
#endif
return 0;
}
......@@ -136,6 +136,10 @@ int main(int argc, const char *argv[]) {
parse_args(argc, argv);
#define TFILE __FILE__ ".tktrace"
unlink(TFILE);
SET_TRACE_FILE(TFILE);
system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777);
......@@ -143,5 +147,7 @@ int main(int argc, const char *argv[]) {
test_insert_zero_length_keys(32, 0, "test0keys");
test_insert_zero_length_keys(32, DB_DUP+DB_DUPSORT, "test0keys_dupsort");
CLOSE_TRACE_FILE();
return 0;
}
......@@ -28,6 +28,16 @@ const char *toku_copyright_string = "Copyright (c) 2007, 2008 Tokutek Inc. All
#include "log.h"
#include "memory.h"
#ifdef TOKUTRACE
#define DB_ENV_CREATE_FUN db_env_create_toku10
#define DB_CREATE_FUN db_create_toku10
#else
#define DB_ENV_CREATE_FUN db_env_create
#define DB_CREATE_FUN db_create
int toku_set_trace_file (char *fname __attribute__((__unused__))) { return 0; }
int toku_close_trace_file (void) { return 0; }
#endif
/** The default maximum number of persistent locks in a lock tree */
const u_int32_t __toku_env_default_max_locks = 1000;
......@@ -761,7 +771,7 @@ cleanup:
return r;
}
int db_env_create(DB_ENV ** envp, u_int32_t flags) {
int DB_ENV_CREATE_FUN (DB_ENV ** envp, u_int32_t flags) {
toku_ydb_lock(); int r = toku_env_create(envp, flags); toku_ydb_unlock(); return r;
}
......@@ -2646,7 +2656,7 @@ static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
return 0;
}
int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
int DB_CREATE_FUN (DB ** db, DB_ENV * env, u_int32_t flags) {
toku_ydb_lock(); int r = toku_db_create(db, env, flags); toku_ydb_unlock(); return r;
}
......
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