Commit 32d7741a authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4555], remove maybe_flush_some from shortcutted path of get_and_pin_with_dep_pairs

git-svn-id: file:///svn/toku/tokudb@40167 c7de825b-a66e-492c-adef-691d508d4ae1
parent 83bf216c
...@@ -176,7 +176,7 @@ static PAIR_ATTR const zero_attr = { ...@@ -176,7 +176,7 @@ static PAIR_ATTR const zero_attr = {
.is_valid = TRUE .is_valid = TRUE
}; };
static void maybe_flush_some (CACHETABLE ct, long size, BOOL ct_locked); static void maybe_flush_some (CACHETABLE ct, long size);
static inline void static inline void
ctpair_add_ref(PAIR p) { ctpair_add_ref(PAIR p) {
...@@ -533,7 +533,7 @@ u_int64_t toku_cachetable_reserve_memory(CACHETABLE ct, double fraction) { ...@@ -533,7 +533,7 @@ u_int64_t toku_cachetable_reserve_memory(CACHETABLE ct, double fraction) {
cachetable_wait_write(ct); cachetable_wait_write(ct);
uint64_t reserved_memory = fraction*(ct->size_limit-ct->size_reserved); uint64_t reserved_memory = fraction*(ct->size_limit-ct->size_reserved);
ct->size_reserved += reserved_memory; ct->size_reserved += reserved_memory;
maybe_flush_some(ct, reserved_memory, TRUE); maybe_flush_some(ct, reserved_memory);
ct->size_current += reserved_memory; ct->size_current += reserved_memory;
cachetable_unlock(ct); cachetable_unlock(ct);
return reserved_memory; return reserved_memory;
...@@ -1616,7 +1616,7 @@ static void cachetable_partial_eviction(WORKITEM wi) { ...@@ -1616,7 +1616,7 @@ static void cachetable_partial_eviction(WORKITEM wi) {
} }
static void maybe_flush_some (CACHETABLE ct, long size, BOOL ct_locked) { static void maybe_flush_some (CACHETABLE ct, long size) {
// //
// These variables will help us detect if everything in the clock is currently being accessed. // These variables will help us detect if everything in the clock is currently being accessed.
...@@ -1629,7 +1629,6 @@ static void maybe_flush_some (CACHETABLE ct, long size, BOOL ct_locked) { ...@@ -1629,7 +1629,6 @@ static void maybe_flush_some (CACHETABLE ct, long size, BOOL ct_locked) {
FILENUM curr_filenum; FILENUM curr_filenum;
curr_filenum.fileid = UINT32_MAX; // create initial value so compiler does not complain curr_filenum.fileid = UINT32_MAX; // create initial value so compiler does not complain
BOOL set_val = FALSE; BOOL set_val = FALSE;
if (!ct_locked) cachetable_lock(ct);
while ((ct->clock_head) && (size + ct->size_current > ct->size_limit + ct->size_evicting)) { while ((ct->clock_head) && (size + ct->size_current > ct->size_limit + ct->size_evicting)) {
PAIR curr_in_clock = ct->clock_head; PAIR curr_in_clock = ct->clock_head;
...@@ -1726,13 +1725,12 @@ static void maybe_flush_some (CACHETABLE ct, long size, BOOL ct_locked) { ...@@ -1726,13 +1725,12 @@ static void maybe_flush_some (CACHETABLE ct, long size, BOOL ct_locked) {
cachetable_rehash(ct, ct->table_size/2); cachetable_rehash(ct, ct->table_size/2);
} }
exit: exit:
if (!ct_locked) cachetable_unlock(ct);
return; return;
} }
void toku_cachetable_maybe_flush_some(CACHETABLE ct) { void toku_cachetable_maybe_flush_some(CACHETABLE ct) {
cachetable_lock(ct); cachetable_lock(ct);
maybe_flush_some(ct, 0, TRUE); maybe_flush_some(ct, 0);
cachetable_unlock(ct); cachetable_unlock(ct);
} }
...@@ -1985,7 +1983,7 @@ int toku_cachetable_put_with_dep_pairs( ...@@ -1985,7 +1983,7 @@ int toku_cachetable_put_with_dep_pairs(
// is used to ensure that a checkpoint is not begun during // is used to ensure that a checkpoint is not begun during
// cachetable_put_internal // cachetable_put_internal
// //
maybe_flush_some(ct, attr.size, TRUE); maybe_flush_some(ct, attr.size);
int rval; int rval;
{ {
BEGIN_CRITICAL_REGION; // checkpoint may not begin inside critical region, detect and crash if one begins BEGIN_CRITICAL_REGION; // checkpoint may not begin inside critical region, detect and crash if one begins
...@@ -2027,7 +2025,7 @@ int toku_cachetable_put(CACHEFILE cachefile, CACHEKEY key, u_int32_t fullhash, v ...@@ -2027,7 +2025,7 @@ int toku_cachetable_put(CACHEFILE cachefile, CACHEKEY key, u_int32_t fullhash, v
CACHETABLE ct = cachefile->cachetable; CACHETABLE ct = cachefile->cachetable;
cachetable_lock(ct); cachetable_lock(ct);
cachetable_wait_write(ct); cachetable_wait_write(ct);
maybe_flush_some(ct, attr.size, TRUE); maybe_flush_some(ct, attr.size);
int r = cachetable_put_internal( int r = cachetable_put_internal(
cachefile, cachefile,
key, key,
...@@ -2235,7 +2233,6 @@ int toku_cachetable_get_and_pin_with_dep_pairs ( ...@@ -2235,7 +2233,6 @@ int toku_cachetable_get_and_pin_with_dep_pairs (
if (!partial_fetch_required && fast_checkpointing) { if (!partial_fetch_required && fast_checkpointing) {
*value = p->value; *value = p->value;
if (sizep) *sizep = p->attr.size; if (sizep) *sizep = p->attr.size;
maybe_flush_some(ct, 0, FALSE);
return 0; return 0;
} }
cachetable_lock(ct); cachetable_lock(ct);
...@@ -2332,7 +2329,7 @@ got_value: ...@@ -2332,7 +2329,7 @@ got_value:
END_CRITICAL_REGION; // checkpoint after this point would no longer cause a threadsafety bug END_CRITICAL_REGION; // checkpoint after this point would no longer cause a threadsafety bug
} }
maybe_flush_some(ct, 0, TRUE); maybe_flush_some(ct, 0);
cachetable_unlock(ct); cachetable_unlock(ct);
WHEN_TRACE_CT(printf("%s:%d did fetch: cachtable_get_and_pin(%lld)--> %p\n", __FILE__, __LINE__, key, *value)); WHEN_TRACE_CT(printf("%s:%d did fetch: cachtable_get_and_pin(%lld)--> %p\n", __FILE__, __LINE__, key, *value));
return 0; return 0;
...@@ -2444,7 +2441,7 @@ cachetable_unpin_internal(CACHEFILE cachefile, CACHEKEY key, u_int32_t fullhash, ...@@ -2444,7 +2441,7 @@ cachetable_unpin_internal(CACHEFILE cachefile, CACHEKEY key, u_int32_t fullhash,
WHEN_TRACE_CT(printf("[count=%lld]\n", p->pinned)); WHEN_TRACE_CT(printf("[count=%lld]\n", p->pinned));
{ {
if (flush) { if (flush) {
maybe_flush_some(ct, 0, TRUE); maybe_flush_some(ct, 0);
} }
} }
r = 0; // we found one r = 0; // we found one
......
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