Add zero option to arena batch allocation
This commit is contained in:
parent
49e5c2fe7d
commit
f805468957
@ -88,7 +88,7 @@ arena_t *arena_choose_huge(tsd_t *tsd);
|
|||||||
bin_t *arena_bin_choose(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
bin_t *arena_bin_choose(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||||
unsigned *binshard);
|
unsigned *binshard);
|
||||||
size_t arena_fill_small_fresh(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
size_t arena_fill_small_fresh(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||||
void **ptrs, size_t nfill);
|
void **ptrs, size_t nfill, bool zero);
|
||||||
void arena_boot(sc_data_t *sc_data);
|
void arena_boot(sc_data_t *sc_data);
|
||||||
void arena_prefork0(tsdn_t *tsdn, arena_t *arena);
|
void arena_prefork0(tsdn_t *tsdn, arena_t *arena);
|
||||||
void arena_prefork1(tsdn_t *tsdn, arena_t *arena);
|
void arena_prefork1(tsdn_t *tsdn, arena_t *arena);
|
||||||
|
@ -885,11 +885,13 @@ label_refill:
|
|||||||
|
|
||||||
size_t
|
size_t
|
||||||
arena_fill_small_fresh(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
arena_fill_small_fresh(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||||
void **ptrs, size_t nfill) {
|
void **ptrs, size_t nfill, bool zero) {
|
||||||
assert(binind < SC_NBINS);
|
assert(binind < SC_NBINS);
|
||||||
const bin_info_t *bin_info = &bin_infos[binind];
|
const bin_info_t *bin_info = &bin_infos[binind];
|
||||||
const size_t nregs = bin_info->nregs;
|
const size_t nregs = bin_info->nregs;
|
||||||
assert(nregs > 0);
|
assert(nregs > 0);
|
||||||
|
const size_t usize = bin_info->reg_size;
|
||||||
|
|
||||||
const bool manual_arena = !arena_is_auto(arena);
|
const bool manual_arena = !arena_is_auto(arena);
|
||||||
unsigned binshard;
|
unsigned binshard;
|
||||||
bin_t *bin = arena_bin_choose(tsdn, arena, binind, &binshard);
|
bin_t *bin = arena_bin_choose(tsdn, arena, binind, &binshard);
|
||||||
@ -911,6 +913,10 @@ arena_fill_small_fresh(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
|||||||
assert(batch > 0);
|
assert(batch > 0);
|
||||||
arena_slab_reg_alloc_batch(slab, bin_info, (unsigned)batch,
|
arena_slab_reg_alloc_batch(slab, bin_info, (unsigned)batch,
|
||||||
&ptrs[filled]);
|
&ptrs[filled]);
|
||||||
|
assert(edata_addr_get(slab) == ptrs[filled]);
|
||||||
|
if (zero) {
|
||||||
|
memset(ptrs[filled], 0, batch * usize);
|
||||||
|
}
|
||||||
filled += batch;
|
filled += batch;
|
||||||
if (batch == nregs) {
|
if (batch == nregs) {
|
||||||
if (manual_arena) {
|
if (manual_arena) {
|
||||||
|
Loading…
Reference in New Issue
Block a user