mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 13:13:06 +00:00
Remove hpa_sec_batch_fill_extra and calculate nallocs automatically.
This change includes the following improvements: - Remove the hpa_sec_batch_fill_extra parameter. - Refactor the hpa_alloc() code and helper functions to be able to allocate more than one extent out of a single pageslab. This way we can amortize the per-pageslab costs (active bitmap iteration, pageslab metadata updates) across multiple extents. - Decide on a min and max number of extents that will be allocated in hpa_alloc(). The code will try to allocate at least the min and allocate up to the max as long as we can allocate additional ones from the pageslab we already have, as additional allocations are relatively cheap. - Add extent allocation distribution stats. - Amend hpa_sec_integration.c unit test.
This commit is contained in:
committed by
Guangli Dai
parent
639e70fcfb
commit
f008ce9fe1
29
src/sec.c
29
src/sec.c
@@ -90,6 +90,35 @@ sec_bin_pick(sec_t *sec, uint8_t shard, pszind_t pszind) {
|
||||
return &sec->bins[ind];
|
||||
}
|
||||
|
||||
void
|
||||
sec_calc_nallocs_for_size(
|
||||
sec_t *sec, size_t size, size_t *min_nallocs_ret, size_t *max_nallocs_ret) {
|
||||
size_t min_nallocs = 1;
|
||||
size_t max_nallocs = 1;
|
||||
|
||||
if (sec_size_supported(sec, size)) {
|
||||
/*
|
||||
* This attempts to fill up to 1/SEC_MAX_BYTES_DIV of the SEC.
|
||||
* If we go much over that, we might cause purging.
|
||||
* This is mainly an issue when max_bytes is small (256K)
|
||||
* and size is large. For larger max_bytes, we will
|
||||
* almost always end up with SEC_MAX_NALLOCS.
|
||||
*/
|
||||
size_t nallocs = sec->opts.max_bytes / size / SEC_MAX_BYTES_DIV;
|
||||
nallocs = max_zu(nallocs, SEC_MIN_NALLOCS);
|
||||
min_nallocs = SEC_MIN_NALLOCS;
|
||||
max_nallocs = min_zu(nallocs, SEC_MAX_NALLOCS);
|
||||
}
|
||||
|
||||
/* post-conditions */
|
||||
assert(1 <= min_nallocs);
|
||||
assert(min_nallocs <= max_nallocs);
|
||||
assert(max_nallocs <= SEC_MAX_NALLOCS);
|
||||
|
||||
*min_nallocs_ret = min_nallocs;
|
||||
*max_nallocs_ret = max_nallocs;
|
||||
}
|
||||
|
||||
static edata_t *
|
||||
sec_bin_alloc_locked(tsdn_t *tsdn, sec_t *sec, sec_bin_t *bin, size_t size) {
|
||||
malloc_mutex_assert_owner(tsdn, &bin->mtx);
|
||||
|
||||
Reference in New Issue
Block a user