thustorage/Sherman

Question regarding cache eviction

juyoungbang opened this issue · 4 comments

Hi.
I'm currently looking into the caching mechanism of Sherman and came up with some questions.

First of all, I have been trying to adjust the amount of index cache used by Sherman
and found that it can be done by changing kIndexCacheSize in Sherman/include/Common.h.
Just to verify, is it the right way to adjust the amount of index cache?

In addition, I also have a question regarding the cache eviction code.
In the get_a_random_entry function, k is selected through the following random function.

auto k = rand_r(&seed) % (1000ull * define::MB);

What I have understood is that, a random key between 0 and 1000ull * define::MB will be selected.
Then it will try to find a cached page which includes the given key range and evict the found page.
My question here is, what if there is no page left which includes the key range between 0 and 1000ull * define::MB?
Will it fail to find a page to evict and fall into a infinite loop (since it continuously retries) ?

Hi.

  1. changing kIndexCacheSize can adjust the size of index cache
  2. (1000ull * define::MB) should be the range of keys.

Thanks.

However, I've encountered one more problem.
The data type of the keys I am using is uint64_t and are quite large values.
But it seems that rand_r is a function returning a integer random number.
So I think it's failing to generate a number in the range of my keys.

Will it be okay to use any other random functions or do you recommend other solutions?

Yes, you can use any other random functions, and our goal is to use power-of-two to evict a node in the cache.

Thanks a lot:)
I'll close the issue.