Add a batch mode for cache_bin_alloc()

This commit is contained in:
Yinan Zhang
2020-10-22 16:07:25 -07:00
parent 4a65f34930
commit be5e49f4fa
2 changed files with 65 additions and 0 deletions

View File

@@ -317,6 +317,18 @@ cache_bin_alloc(cache_bin_t *bin, bool *success) {
return cache_bin_alloc_impl(bin, success, true);
}
JEMALLOC_ALWAYS_INLINE cache_bin_sz_t
cache_bin_alloc_batch(cache_bin_t *bin, size_t num, void **out) {
size_t n = cache_bin_ncached_get_internal(bin);
if (n > num) {
n = num;
}
memcpy(out, bin->stack_head, n * sizeof(void *));
bin->stack_head += n;
cache_bin_low_water_adjust(bin);
return n;
}
/*
* Free an object into the given bin. Fails only if the bin is full.
*/