Tcache batching: Plumbing

In the next commit, we'll start using the batcher to eliminate mutex traffic.
To avoid cluttering up that commit with the random bits of busy-work it entails,
we'll centralize them here.  This commit introduces:
- A batched bin type.
- The ability to mix batched and unbatched bins in the arena.
- Conf parsing to set batches per size and a max batched size.
- mallctl access to the corresponding opt-namespace keys.
- Stats output of the above.
This commit is contained in:
David Goldblatt
2024-02-02 13:20:14 -08:00
committed by David Goldblatt
parent 70c94d7474
commit c085530c71
11 changed files with 121 additions and 35 deletions

View File

@@ -54,16 +54,28 @@ bin_init(bin_t *bin) {
}
void
bin_prefork(tsdn_t *tsdn, bin_t *bin) {
bin_prefork(tsdn_t *tsdn, bin_t *bin, bool has_batch) {
malloc_mutex_prefork(tsdn, &bin->lock);
if (has_batch) {
bin_with_batch_t *batched = (bin_with_batch_t *)bin;
batcher_prefork(tsdn, &batched->remote_frees);
}
}
void
bin_postfork_parent(tsdn_t *tsdn, bin_t *bin) {
bin_postfork_parent(tsdn_t *tsdn, bin_t *bin, bool has_batch) {
malloc_mutex_postfork_parent(tsdn, &bin->lock);
if (has_batch) {
bin_with_batch_t *batched = (bin_with_batch_t *)bin;
batcher_postfork_parent(tsdn, &batched->remote_frees);
}
}
void
bin_postfork_child(tsdn_t *tsdn, bin_t *bin) {
bin_postfork_child(tsdn_t *tsdn, bin_t *bin, bool has_batch) {
malloc_mutex_postfork_child(tsdn, &bin->lock);
if (has_batch) {
bin_with_batch_t *batched = (bin_with_batch_t *)bin;
batcher_postfork_child(tsdn, &batched->remote_frees);
}
}