jemalloc/test/unit
Dmitry Ilvokhin ad108d50f1 Extend purging algorithm with peak demand tracking
Implementation inspired by idea described in "Beyond malloc efficiency
to fleet efficiency: a hugepage-aware memory allocator" paper [1].

Primary idea is to track maximum number (peak) of active pages in use
with sliding window and then use this number to decide how many dirty
pages we would like to keep.

We are trying to estimate maximum amount of active memory we'll need in
the near future. We do so by projecting future active memory demand
(based on peak active memory usage we observed in the past within
sliding window) and adding slack on top of it (an overhead is reasonable
to have in exchange of higher hugepages coverage). When peak demand
tracking is off, projection of future active memory is active memory we
are having right now.

Estimation is essentially the same as `nactive_max * (1 + dirty_mult)`.

Peak demand purging algorithm controlled by two config options. Option
`hpa_peak_demand_window_ms` controls duration of sliding window we track
maximum active memory usage in and option `hpa_dirty_mult` controls
amount of slack we are allowed to have as a percent from maximum active
memory usage. By default `hpa_peak_demand_window_ms == 0` now and we
have same behaviour (ratio based purging) that we had before this
commit.

[1]: https://storage.googleapis.com/gweb-research2023-media/pubtools/6170.pdf
2025-03-13 10:12:22 -07:00
..
a0.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
arena_decay.c Cache extra extents in the dirty pool from ecache_alloc_grow 2025-03-06 15:08:13 -08:00
arena_decay.sh Allow opt.tcache_max to accept small size classes. 2020-10-24 20:43:44 -07:00
arena_reset.c Introducing a new usize calculation policy 2025-03-06 15:08:13 -08:00
arena_reset_prof.c Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
arena_reset_prof.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
atomic.c Fix shadowed variable usage. 2021-12-23 10:55:08 -08:00
background_thread.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
background_thread_enable.c Check for 0 input when setting max_background_thread through mallctl. 2025-01-28 10:38:56 -08:00
base.c metadata usage breakdowns: tracking edata and rtree usages 2023-10-11 11:56:01 -07:00
batch_alloc.c Enable per-tcache tcache_max 2023-09-06 10:47:14 -07:00
batch_alloc.sh Add batch allocation API 2020-07-31 09:16:50 -07:00
batch_alloc_prof.c Add batch allocation API 2020-07-31 09:16:50 -07:00
batch_alloc_prof.sh Add batch allocation API 2020-07-31 09:16:50 -07:00
batcher.c Add batcher module. 2024-05-22 10:30:31 -07:00
bin_batching.c Fix initialization of pop_attempt_results in bin_batching test 2024-09-12 11:36:17 -07:00
bin_batching.sh Add batching to arena bins. 2024-05-22 10:30:31 -07:00
binshard.c PA: Parameterize emap. Move emap_global to arena. 2020-04-10 13:12:47 -07:00
binshard.sh Add unit test for sharded bins. 2018-12-03 17:17:03 -08:00
bit_util.c Make eligible functions static 2023-05-08 15:00:02 -07:00
bitmap.c bitset test: Pull NBITS_TAB into its own file. 2020-07-30 15:25:23 -07:00
buf_writer.c Add piping API to buffered writer 2020-04-01 09:41:20 -07:00
cache_bin.c Cleanup cache_bin_info_t* info input args 2023-10-25 10:27:31 -07:00
ckh.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
counter.c Migrate counter to use locked int 2020-05-12 08:23:15 -07:00
decay.c Wake up background threads on demand 2021-09-17 16:56:41 -07:00
div.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
double_free.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
double_free.h Eagerly detect double free and sized dealloc bugs for large sizes. 2020-10-15 10:03:16 -07:00
edata_cache.c add experimental.arenas_create_ext mallctl 2021-09-24 13:43:18 -07:00
emitter.c Emit long string values without truncation 2024-07-29 13:58:31 -07:00
extent_quantize.c Implement opt.cache_oblivious. 2021-02-11 11:32:01 -08:00
fb.c Travis: Unbreak the builds. 2021-06-24 07:40:28 -07:00
fork.c Add batching to arena bins. 2024-05-22 10:30:31 -07:00
fxp.c fxp: Add FXP_INIT_PERCENT 2021-02-04 20:58:31 -08:00
hash.c Fix integer overflow in test/unit/hash.c 2025-01-17 12:54:22 -08:00
hook.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
hpa.c Extend purging algorithm with peak demand tracking 2025-03-13 10:12:22 -07:00
hpa_background_thread.c Fix arena 0 deferral_allowed flag init 2025-02-18 12:10:35 -08:00
hpa_background_thread.sh Remove validation for HPA ratios 2024-11-20 18:59:07 -08:00
hpdata.c HPA: Purge across retained extents. 2021-07-12 17:59:18 -07:00
huge.c Avoid assuming the arena id in test when percpu_arena is used. 2023-03-13 10:50:10 -07:00
inspect.c Inspect test: Reduce checks when profiling is on. 2020-03-12 11:58:09 -07:00
inspect.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
junk.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
junk.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
junk_alloc.c Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
junk_alloc.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
junk_free.c Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
junk_free.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
log.c Travis: Unbreak the builds. 2021-06-24 07:40:28 -07:00
mallctl.c Extend purging algorithm with peak demand tracking 2025-03-13 10:12:22 -07:00
malloc_conf_2.c print out all malloc_conf settings in stats 2024-02-29 12:12:44 -08:00
malloc_conf_2.sh Add malloc_conf_2_conf_harder 2020-03-31 06:25:08 -07:00
malloc_io.c IO: Support 0-padding for unsigned numbers. 2020-08-13 10:03:15 -07:00
math.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
mpsc_queue.c mpsc_queue: Add module. 2021-06-24 14:55:49 -07:00
mq.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
mtx.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
ncached_max.c Refactor the tcache initiailization 2023-10-18 14:11:46 -07:00
nstime.c Add nstime_ms_since to get time since in ms 2024-11-08 10:37:28 -08:00
oversize_threshold.c Avoid eager purging on the dedicated oversize arena when using bg thds. 2023-06-27 11:57:41 -07:00
pa.c Make eligible functions static 2023-05-08 15:00:02 -07:00
pack.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
pack.sh Refactor *decay_time into *decay_ms. 2017-05-18 11:33:45 -07:00
pages.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
peak.c Add peak_t, for tracking allocator net max. 2020-06-11 13:54:22 -07:00
peak_demand.c Extend purging algorithm with peak demand tracking 2025-03-13 10:12:22 -07:00
ph.c Introducing a new usize calculation policy 2025-03-06 15:08:13 -08:00
prng.c PRNG test: cleanups. 2020-10-05 19:55:57 -07:00
prof_accum.c Move file handling logic in prof_data to prof_sys 2020-06-29 14:27:50 -07:00
prof_accum.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
prof_active.c Expose prof_data testing internals only in prof tests 2020-06-29 14:27:50 -07:00
prof_active.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
prof_gdump.c HPA: Tie components into a PAI implementation. 2020-10-23 11:14:34 -07:00
prof_gdump.sh Enable heap profiling on MacOS 2024-04-09 12:57:01 -07:00
prof_hook.c Add usize to prof_sample_hook_t 2024-07-30 10:29:30 -07:00
prof_hook.sh Making jemalloc max stack depth a runtime option 2022-09-12 13:56:22 -07:00
prof_idump.c Fix shadowed variable usage. 2021-12-23 10:55:08 -08:00
prof_idump.sh Remove --disable-tcache. 2017-04-21 10:06:12 -07:00
prof_log.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
prof_log.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
prof_mdump.c Enable heap profiling on MacOS 2024-04-09 12:57:01 -07:00
prof_mdump.sh Push error handling logic out of core dumping logic 2020-06-29 14:27:50 -07:00
prof_recent.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
prof_recent.sh Add the prof_sys_thread_name feature in the prof_recent unit test. 2023-05-11 09:10:57 -07:00
prof_reset.c Fix shadowed variable usage. 2021-12-23 10:55:08 -08:00
prof_reset.sh Last-N profiling mode 2019-12-30 15:58:57 -08:00
prof_small.c Fix profiling sample metadata lookup during xallocx 2025-03-04 14:42:04 -08:00
prof_small.sh Add a test-case for small profiled allocations 2023-07-03 16:19:06 -07:00
prof_stats.c Darwin malloc_size override support proposal. 2021-10-01 14:32:40 -07:00
prof_stats.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
prof_sys_thread_name.c Add a multithreaded test for prof_sys_thread_name. 2023-04-05 10:03:12 -07:00
prof_sys_thread_name.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
prof_tctx.c Define PROF_TCTX_SENTINEL instead of using magic numbers 2023-07-24 14:40:42 -07:00
prof_tctx.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
prof_thread_name.c Inline the storage for thread name in prof_tdata_t. 2023-04-05 10:03:12 -07:00
prof_thread_name.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
prof_threshold.c Avoid implicit conversion in test/unit/prof_threshold 2025-01-31 10:18:36 -08:00
prof_threshold_small.c Unlike prof_sample which is supported only with profiling mode active, prof_threshold is intended to be an always-supported allocation callback with much less overhead. The usage of the threshold allows performance critical callers to change program execution based on the callback: e.g. drop caches when memory becomes high or to predict the program is about to OOM ahead of time using peak memory watermarks. 2025-01-29 18:55:52 -08:00
prof_threshold_small.sh Unlike prof_sample which is supported only with profiling mode active, prof_threshold is intended to be an always-supported allocation callback with much less overhead. The usage of the threshold allows performance critical callers to change program execution based on the callback: e.g. drop caches when memory becomes high or to predict the program is about to OOM ahead of time using peak memory watermarks. 2025-01-29 18:55:52 -08:00
psset.c Disable psset test when hugepage size is too large. 2024-12-17 12:35:35 -08:00
ql.c Add move constructor to ql module 2020-04-06 09:50:27 -07:00
qr.c Optimize meld in qr module 2020-04-06 09:50:27 -07:00
rb.c Fix shadowed variable usage. 2021-12-23 10:55:08 -08:00
retained.c Fix test_retained on boxes with a lot of CPUs 2024-12-02 14:12:26 -08:00
rtree.c Small refactors around 7bb05e0. 2021-09-27 16:05:13 -07:00
safety_check.c Avoid overflow warnings in test/unit/safety_check. 2022-01-27 10:29:54 -08:00
safety_check.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
san.c San: Bump alloc frequently reused guarded allocations 2021-12-15 10:39:17 -08:00
san.sh San: Rename 'guard' to 'san' 2021-12-15 10:39:17 -08:00
san_bump.c Rename 'arena_decay' to 'arena_util' 2021-12-15 10:39:17 -08:00
sc.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
sec.c Introducing a new usize calculation policy 2025-03-06 15:08:13 -08:00
seq.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
SFMT.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
size_check.c Make eligible functions static 2023-05-08 15:00:02 -07:00
size_check.sh Add the profiling settings for tests explicit. 2021-12-22 20:10:28 -08:00
size_classes.c Introducing a new usize calculation policy 2025-03-06 15:08:13 -08:00
size_classes.sh Introducing a new usize calculation policy 2025-03-06 15:08:13 -08:00
slab.c Tcache flush: keep common path state in registers. 2021-02-04 14:10:43 -08:00
smoothstep.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
spin.c Header refactoring: unify and de-catchall rtree module. 2017-05-31 13:08:45 -07:00
stats.c Introducing a new usize calculation policy 2025-03-06 15:08:13 -08:00
stats_print.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
sz.c fix some typos 2022-04-25 11:29:00 -07:00
tcache_max.c Cleanup cache_bin_info_t* info input args 2023-10-25 10:27:31 -07:00
tcache_max.sh skip tcache GC for tcache_max unit test 2024-06-25 12:59:45 -07:00
test_hooks.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
thread_event.c Remove thread_event_rollback() 2020-03-12 13:55:00 -07:00
thread_event.sh Build a general purpose thread event handler 2019-11-04 11:15:50 -08:00
ticker.c Disallow decay during reentrancy. 2023-04-05 10:16:37 -07:00
tsd.c Enable fast thread locals for dealloc-only threads. 2022-10-25 09:54:38 -07:00
uaf.c Fix test config of lg_san_uaf_align. 2022-01-04 11:03:51 -08:00
witness.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
zero.c Change assert_* to expect_* in tests 2020-02-19 16:03:16 -08:00
zero.sh Use MALLOC_CONF rather than malloc_conf for tests. 2017-02-23 08:57:02 -08:00
zero_realloc_abort.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
zero_realloc_abort.sh Realloc: Make behavior of realloc(ptr, 0) configurable. 2019-10-29 17:48:44 -07:00
zero_realloc_alloc.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
zero_realloc_alloc.sh Rename zero_realloc option "strict" to "alloc". 2022-04-20 10:27:25 -07:00
zero_realloc_free.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
zero_realloc_free.sh Realloc: Make behavior of realloc(ptr, 0) configurable. 2019-10-29 17:48:44 -07:00
zero_reallocs.c Enabled -Wstrict-prototypes and fixed warnings. 2023-07-06 12:00:02 -07:00
zero_reallocs.sh Add stats counters for number of zero reallocs 2019-10-29 17:48:44 -07:00