Track low_water == -1 case explicitly.

The -1 value of low_water indicates if the cache has been depleted and
refilled.  Track the status explicitly in the tcache struct.

This allows the fast path to check if (cur_ptr > low_water), instead of >=,
which avoids reaching slow path when the last item is allocated.
This commit is contained in:
Qi Wang
2019-08-20 18:14:18 -07:00
committed by Qi Wang
parent 937ca1db9f
commit 0043e68d4c
5 changed files with 23 additions and 17 deletions

View File

@@ -23,7 +23,7 @@ TEST_BEGIN(test_cache_bin) {
bool success;
void *ret = cache_bin_alloc_easy(bin, &success, 0);
assert_false(success, "Empty cache bin should not alloc");
assert_true(cache_bin_low_water_get(bin, 0) == - 1,
assert_true(cache_bin_low_water_get(bin, 0) == 0,
"Incorrect low water mark");
cache_bin_ncached_set(bin, 0, 0);