Commit 00ac50e3 authored by Yoni Fogel's avatar Yoni Fogel

refs #5802 Fix calculations for probabilistic clock,

take into account things could be negative (so use int64_ts instead of uint_64) and set appropriate max for size_current

git-svn-id: file:///svn/toku/tokudb@51207 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3ad68549
...@@ -3771,7 +3771,7 @@ bool evictor::run_eviction_on_pair(PAIR curr_in_clock) { ...@@ -3771,7 +3771,7 @@ bool evictor::run_eviction_on_pair(PAIR curr_in_clock) {
curr_in_clock->count--; curr_in_clock->count--;
} else { } else {
// generate a random number between 0 and 2^16 // generate a random number between 0 and 2^16
assert(size_current < (1LL<<48)); // to protect against possible overflows assert(size_current <= (INT64_MAX / ((1<<16)-1))); // to protect against possible overflows
int32_t rnd = myrandom_r(&m_random_data) % (1<<16); int32_t rnd = myrandom_r(&m_random_data) % (1<<16);
// The if-statement below will be true with probability of // The if-statement below will be true with probability of
// curr_size/(average size of PAIR in cachetable) // curr_size/(average size of PAIR in cachetable)
...@@ -3788,7 +3788,7 @@ bool evictor::run_eviction_on_pair(PAIR curr_in_clock) { ...@@ -3788,7 +3788,7 @@ bool evictor::run_eviction_on_pair(PAIR curr_in_clock) {
// and dividing each side by 2^16, // and dividing each side by 2^16,
// we get the if-clause below // we get the if-clause below
// //
if ((((uint64_t)curr_size) * n_in_table) >= (((uint64_t)rnd) * size_current)>>16) { if ((((int64_t)curr_size) * n_in_table) >= (((int64_t)rnd) * size_current)>>16) {
curr_in_clock->count--; curr_in_clock->count--;
} }
} }
......
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