Commit a4f62276 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3379 benchmark put multiple refs[t:3379]

git-svn-id: file:///svn/toku/tokudb@29571 c7de825b-a66e-492c-adef-691d508d4ae1
parent ccb394d9
TARGETS = db-insert db-insert-bdb db-scan db-scan-bdb db-update db-update-bdb TARGETS = db-insert db-insert-bdb db-scan db-scan-bdb db-update db-update-bdb db-insert-multiple
CFLAGS = -g CPPFLAGS = -I../include -D_GNU_SOURCE
CPPFLAGS = -I../include CFLAGS = -g -std=c99 -Wall -Werror
LIBTOKUDB = tokudb LIBTOKUDB = tokudb
LDFLAGS = -L../lib -l$(LIBTOKUDB) -Wl,-rpath,../lib LDFLAGS = -L../lib -l$(LIBTOKUDB) -Wl,-rpath,../lib
default: $(TARGETS) default: $(TARGETS)
db-insert-bdb: db-insert.c db-insert-bdb: db-insert.c
cc -ldb db-insert.c -o db-insert-bdb -DBDB $(CFLAGS) cc -D_GNU_SOURCE -DBDB $(CFLAGS) db-insert.c -o db-insert-bdb -ldb
db-scan-bdb: db-scan.c db-scan-bdb: db-scan.c
cc -ldb db-scan.c -o db-scan-bdb -DBDB $(CFLAGS) cc -D_GNU_SOURCE -DBDB $(CFLAGS) db-scan.c -o db-scan-bdb -ldb
db-update-bdb: db-update.c db-update-bdb: db-update.c
cc -ldb db-update.c -o db-update-bdb -DBDB $(CFLAGS) cc -D_GNU_SOURCE -DBDB $(CFLAGS) db-update.c -o db-update-bdb -ldb
default: db-insert default: db-insert
......
This diff is collapsed.
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#ifdef BDB #ifdef BDB
#include <sys/types.h>
#include <db.h> #include <db.h>
#define DIRSUF bdb #define DIRSUF bdb
#else #else
......
...@@ -6,9 +6,12 @@ ...@@ -6,9 +6,12 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include "db.h" #include "db.h"
#if defined(BDB) #if defined(BDB)
...@@ -23,7 +26,7 @@ static int get_int(void *p) { ...@@ -23,7 +26,7 @@ static int get_int(void *p) {
return htonl(v); return htonl(v);
} }
#if !defined(BDB) #if defined(TOKUDB)
static int my_update_callback(DB *db, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra) { static int my_update_callback(DB *db, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *new_val, void *set_extra), void *set_extra) {
if (old_val == NULL) { if (old_val == NULL) {
// insert new_val = extra // insert new_val = extra
...@@ -62,7 +65,7 @@ static void insert_and_update(DB_ENV *db_env, DB *db, DB_TXN *txn, int a, int b, ...@@ -62,7 +65,7 @@ static void insert_and_update(DB_ENV *db_env, DB *db, DB_TXN *txn, int a, int b,
int newd = htonl(d); int newd = htonl(d);
memcpy(val_buffer+4, &newd, sizeof newd); memcpy(val_buffer+4, &newd, sizeof newd);
#if !defined(BDB) #if defined(TOKUDB)
if (do_update_callback) { if (do_update_callback) {
// extra = value_buffer, implicit combine column c update function // extra = value_buffer, implicit combine column c update function
DBT key = { .data = key_buffer, .size = sizeof key_buffer }; DBT key = { .data = key_buffer, .size = sizeof key_buffer };
...@@ -147,6 +150,7 @@ int main(int argc, char *argv[]) { ...@@ -147,6 +150,7 @@ int main(int argc, char *argv[]) {
int key_range = 100000; int key_range = 100000;
bool do_update_callback = false; bool do_update_callback = false;
bool do_txn = true; bool do_txn = true;
u_int64_t cachesize = 0;
u_int32_t pagesize = 0; u_int32_t pagesize = 0;
int i; int i;
...@@ -180,6 +184,10 @@ int main(int argc, char *argv[]) { ...@@ -180,6 +184,10 @@ int main(int argc, char *argv[]) {
pagesize = atoi(argv[++i]); pagesize = atoi(argv[++i]);
continue; continue;
} }
if (strcmp(arg, "--cachesize") == 0 && i+1 < argc) {
cachesize = atol(argv[++i]);
continue;
}
if (strcmp(arg, "--update_callback") == 0) { if (strcmp(arg, "--update_callback") == 0) {
do_update_callback = true; do_update_callback = true;
continue; continue;
...@@ -198,9 +206,13 @@ int main(int argc, char *argv[]) { ...@@ -198,9 +206,13 @@ int main(int argc, char *argv[]) {
// create and open the env // create and open the env
DB_ENV *db_env = NULL; DB_ENV *db_env = NULL;
r = db_env_create(&db_env, 0); assert(r == 0); r = db_env_create(&db_env, 0); assert(r == 0);
#if !defined(BDB) #if defined(TOKUDB)
db_env->set_update(db_env, my_update_callback); db_env->set_update(db_env, my_update_callback);
#endif #endif
if (cachesize) {
const u_int64_t gig = 1 << 30;
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
if (!do_txn) if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG); db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0); r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
......
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