Commit dcfbff56 authored by Rich Prohaska's avatar Rich Prohaska

more the root_put_counter to the brt object. this speeds up cursor...

more the root_put_counter to the brt object.  this speeds up cursor operations.  we will address multiple brt handles later. addresses #1054


git-svn-id: file:///svn/tokudb@5651 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8dd1d28b
...@@ -127,8 +127,6 @@ struct brt_header { ...@@ -127,8 +127,6 @@ struct brt_header {
unsigned int *flags_array; // an array of flags. Element 0 holds the element if no subdatabases allowed. unsigned int *flags_array; // an array of flags. Element 0 holds the element if no subdatabases allowed.
FIFO fifo; // all the abort and commit commands. If the header gets flushed to disk, we write the fifo contents beyond the unused_memory. FIFO fifo; // all the abort and commit commands. If the header gets flushed to disk, we write the fifo contents beyond the unused_memory.
u_int64_t root_put_counter;
}; };
struct brt { struct brt {
...@@ -151,6 +149,7 @@ struct brt { ...@@ -151,6 +149,7 @@ struct brt {
OMT txns; // transactions that are using this OMT (note that the transaction checks the cf also) OMT txns; // transactions that are using this OMT (note that the transaction checks the cf also)
u_int64_t txn_that_created; // which txn created it. Use 0 if no such txn. u_int64_t txn_that_created; // which txn created it. Use 0 if no such txn.
u_int64_t root_put_counter;
}; };
/* serialization code */ /* serialization code */
......
...@@ -232,7 +232,6 @@ int toku_brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, u_int3 ...@@ -232,7 +232,6 @@ int toku_brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, u_int3
if ((r = toku_deserialize_fifo_at(toku_cachefile_fd(cachefile), (*h)->unused_memory, &(*h)->fifo))) return r; if ((r = toku_deserialize_fifo_at(toku_cachefile_fd(cachefile), (*h)->unused_memory, &(*h)->fifo))) return r;
//printf("%s:%d fifo=%p\nn", __FILE__, __LINE__, (*h)->fifo); //printf("%s:%d fifo=%p\nn", __FILE__, __LINE__, (*h)->fifo);
written_lsn->lsn = 0; // !!! WRONG. This should be stored or kept redundantly or something. written_lsn->lsn = 0; // !!! WRONG. This should be stored or kept redundantly or something.
(*h)->root_put_counter = global_root_put_counter++;
return 0; return 0;
} }
...@@ -2171,7 +2170,7 @@ static int brt_alloc_init_header(BRT t, const char *dbname, TOKUTXN txn) { ...@@ -2171,7 +2170,7 @@ static int brt_alloc_init_header(BRT t, const char *dbname, TOKUTXN txn) {
t->h->freelist=-1; t->h->freelist=-1;
t->h->unused_memory=2*t->nodesize; t->h->unused_memory=2*t->nodesize;
toku_fifo_create(&t->h->fifo); toku_fifo_create(&t->h->fifo);
t->h->root_put_counter = global_root_put_counter++; t->root_put_counter = global_root_put_counter++;
if (dbname) { if (dbname) {
t->h->n_named_roots = 1; t->h->n_named_roots = 1;
if ((MALLOC_N(1, t->h->names))==0) { assert(errno==ENOMEM); r=ENOMEM; if (0) { died4: if (dbname) toku_free(t->h->names); } goto died3; } if ((MALLOC_N(1, t->h->names))==0) { assert(errno==ENOMEM); r=ENOMEM; if (0) { died4: if (dbname) toku_free(t->h->names); } goto died3; }
...@@ -2615,7 +2614,7 @@ int toku_brt_root_put_cmd(BRT brt, BRT_CMD cmd, TOKULOGGER logger) { ...@@ -2615,7 +2614,7 @@ int toku_brt_root_put_cmd(BRT brt, BRT_CMD cmd, TOKULOGGER logger) {
return r; return r;
} }
brt->h->root_put_counter = global_root_put_counter++; brt->root_put_counter = global_root_put_counter++;
u_int32_t fullhash; u_int32_t fullhash;
rootp = toku_calculate_root_offset_pointer(brt, &fullhash); rootp = toku_calculate_root_offset_pointer(brt, &fullhash);
//assert(fullhash==toku_cachetable_hash(brt->cf, *rootp)); //assert(fullhash==toku_cachetable_hash(brt->cf, *rootp));
...@@ -3042,7 +3041,7 @@ int toku_brt_search(BRT brt, brt_search_t *search, DBT *newkey, DBT *newval, TOK ...@@ -3042,7 +3041,7 @@ int toku_brt_search(BRT brt, brt_search_t *search, DBT *newkey, DBT *newval, TOK
rr = toku_read_and_pin_brt_header(brt->cf, &brt->h); rr = toku_read_and_pin_brt_header(brt->cf, &brt->h);
assert(rr == 0); assert(rr == 0);
*root_put_counter = brt->h->root_put_counter; *root_put_counter = brt->root_put_counter;
u_int32_t fullhash; u_int32_t fullhash;
CACHEKEY *rootp = toku_calculate_root_offset_pointer(brt, &fullhash); CACHEKEY *rootp = toku_calculate_root_offset_pointer(brt, &fullhash);
...@@ -3420,11 +3419,7 @@ static int brt_cursor_next_shortcut (BRT_CURSOR cursor, DBT *outkey, DBT *outval ...@@ -3420,11 +3419,7 @@ static int brt_cursor_next_shortcut (BRT_CURSOR cursor, DBT *outkey, DBT *outval
{ {
if (toku_omt_cursor_is_valid(cursor->omtcursor)) { if (toku_omt_cursor_is_valid(cursor->omtcursor)) {
{ {
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h); u_int64_t h_counter = cursor->brt->root_put_counter;
if (rr!=0) return rr;
u_int64_t h_counter = cursor->brt->h->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1; if (h_counter != cursor->root_put_counter) return -1;
} }
OMTVALUE le; OMTVALUE le;
...@@ -3463,7 +3458,7 @@ int toku_brt_cursor_peek_prev(BRT_CURSOR cursor, DBT *outkey, DBT *outval) { ...@@ -3463,7 +3458,7 @@ int toku_brt_cursor_peek_prev(BRT_CURSOR cursor, DBT *outkey, DBT *outval) {
{ {
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h); int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h);
if (rr!=0) return rr; if (rr!=0) return rr;
u_int64_t h_counter = cursor->brt->h->root_put_counter; u_int64_t h_counter = cursor->brt->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt); rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0); assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1; if (h_counter != cursor->root_put_counter) return -1;
...@@ -3492,7 +3487,7 @@ int toku_brt_cursor_peek_next(BRT_CURSOR cursor, DBT *outkey, DBT *outval) { ...@@ -3492,7 +3487,7 @@ int toku_brt_cursor_peek_next(BRT_CURSOR cursor, DBT *outkey, DBT *outval) {
{ {
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h); int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h);
if (rr!=0) return rr; if (rr!=0) return rr;
u_int64_t h_counter = cursor->brt->h->root_put_counter; u_int64_t h_counter = cursor->brt->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt); rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0); assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1; if (h_counter != cursor->root_put_counter) return -1;
...@@ -3583,11 +3578,7 @@ static int brt_cursor_prev_shortcut (BRT_CURSOR cursor, DBT *outkey, DBT *outval ...@@ -3583,11 +3578,7 @@ static int brt_cursor_prev_shortcut (BRT_CURSOR cursor, DBT *outkey, DBT *outval
{ {
if (toku_omt_cursor_is_valid(cursor->omtcursor)) { if (toku_omt_cursor_is_valid(cursor->omtcursor)) {
{ {
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h); u_int64_t h_counter = cursor->brt->root_put_counter;
if (rr!=0) return rr;
u_int64_t h_counter = cursor->brt->h->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1; if (h_counter != cursor->root_put_counter) return -1;
} }
OMTVALUE le; OMTVALUE le;
......
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