From d202218e865a14d8fcff5c41682719a07434518c Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Thu, 3 Jun 2021 17:14:43 -0700 Subject: [PATCH] HPA: Fix typos with big performance implications. This fixes two simple but significant typos in the HPA: - The conf string parsing accidentally set a min value of PAGE for hpa_sec_batch_fill_extra; i.e. allocating 4096 extra pages every time we attempted to allocate a single page. This puts us over the SEC flush limit, so we then immediately flush all but one of them (probably triggering purging). - The HPA was using the default PAI batch alloc implementation, which meant it did not actually get any locking advantages. This snuck by because I did all the performance testing without using the PAI interface or config settings. When I cleaned it up and put everything behind nice interfaces, I only did correctness checks, and didn't try any performance ones. --- src/hpa.c | 2 +- src/jemalloc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hpa.c b/src/hpa.c index 22cf0072..8ef881fd 100644 --- a/src/hpa.c +++ b/src/hpa.c @@ -92,7 +92,7 @@ hpa_shard_init(hpa_shard_t *shard, emap_t *emap, base_t *base, * operating on corrupted data. */ shard->pai.alloc = &hpa_alloc; - shard->pai.alloc_batch = &pai_alloc_batch_default; + shard->pai.alloc_batch = &hpa_alloc_batch; shard->pai.expand = &hpa_expand; shard->pai.shrink = &hpa_shrink; shard->pai.dalloc = &hpa_dalloc; diff --git a/src/jemalloc.c b/src/jemalloc.c index c70244d1..6ff9f97b 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1489,8 +1489,8 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS], "hpa_sec_bytes_after_flush", PAGE, 0, CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, true); CONF_HANDLE_SIZE_T(opt_hpa_sec_opts.batch_fill_extra, - "hpa_sec_batch_fill_extra", PAGE, 0, CONF_CHECK_MIN, - CONF_DONT_CHECK_MAX, true); + "hpa_sec_batch_fill_extra", 0, HUGEPAGE_PAGES, + CONF_CHECK_MIN, CONF_CHECK_MAX, true); if (CONF_MATCH("slab_sizes")) { if (CONF_MATCH_VALUE("default")) {