diff --git a/include/jemalloc/internal/tcache_externs.h b/include/jemalloc/internal/tcache_externs.h index e043ef49..1924fd9c 100644 --- a/include/jemalloc/internal/tcache_externs.h +++ b/include/jemalloc/internal/tcache_externs.h @@ -8,6 +8,7 @@ extern unsigned opt_tcache_nslots_small_min; extern unsigned opt_tcache_nslots_small_max; extern unsigned opt_tcache_nslots_large; extern ssize_t opt_lg_tcache_shift; +extern size_t opt_tcache_gc_incr_bytes; /* * Number of tcache bins. There are SC_NBINS small-object bins, plus 0 or more diff --git a/include/jemalloc/internal/tcache_types.h b/include/jemalloc/internal/tcache_types.h index c8fd4c3e..fb311e72 100644 --- a/include/jemalloc/internal/tcache_types.h +++ b/include/jemalloc/internal/tcache_types.h @@ -17,9 +17,6 @@ typedef struct tcaches_s tcaches_t; #define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3) #define TCACHE_STATE_MAX TCACHE_STATE_PURGATORY -/* Number of allocation bytes between tcache incremental GCs. */ -#define TCACHE_GC_INCR_BYTES 65536U - /* Used in TSD static initializer only. Real init in tsd_tcache_data_init(). */ #define TCACHE_ZERO_INITIALIZER {0} #define TCACHE_SLOW_ZERO_INITIALIZER {0} diff --git a/include/jemalloc/internal/thread_event.h b/include/jemalloc/internal/thread_event.h index 5b5bb9fb..2fcaa88a 100644 --- a/include/jemalloc/internal/thread_event.h +++ b/include/jemalloc/internal/thread_event.h @@ -53,10 +53,10 @@ void tsd_te_init(tsd_t *tsd); * E(event, (condition), is_alloc_event) */ #define ITERATE_OVER_ALL_EVENTS \ - E(tcache_gc, (TCACHE_GC_INCR_BYTES > 0), true) \ + E(tcache_gc, (opt_tcache_gc_incr_bytes > 0), true) \ E(prof_sample, (config_prof && opt_prof), true) \ E(stats_interval, (opt_stats_interval >= 0), true) \ - E(tcache_gc_dalloc, (TCACHE_GC_INCR_BYTES > 0), false) + E(tcache_gc_dalloc, (opt_tcache_gc_incr_bytes > 0), false) #define E(event, condition_unused, is_alloc_event_unused) \ C(event##_event_wait) diff --git a/src/jemalloc.c b/src/jemalloc.c index 4f911e22..068a840a 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1389,6 +1389,10 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS], CONF_HANDLE_UNSIGNED(opt_tcache_nslots_large, "tcache_nslots_large", 1, 2048, CONF_CHECK_MIN, CONF_CHECK_MAX, /* clip */ true) + CONF_HANDLE_SIZE_T(opt_tcache_gc_incr_bytes, + "tcache_gc_incr_bytes", 1024, SIZE_T_MAX, + CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, + /* clip */ true) /* * The runtime option of oversize_threshold remains diff --git a/src/tcache.c b/src/tcache.c index 0366149d..9b4a7b7a 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -33,6 +33,12 @@ unsigned opt_tcache_nslots_large = 20; */ ssize_t opt_lg_tcache_nslots_mul = -1; +/* + * Number of allocation bytes between tcache incremental GCs. Again, this + * default just seems to work well; more tuning is possible. + */ +size_t opt_tcache_gc_incr_bytes = 65536; + cache_bin_info_t *tcache_bin_info; /* Total stack size required (per tcache). Include the padding above. */ @@ -62,7 +68,7 @@ tcache_salloc(tsdn_t *tsdn, const void *ptr) { uint64_t tcache_gc_new_event_wait(tsd_t *tsd) { - return TCACHE_GC_INCR_BYTES; + return opt_tcache_gc_incr_bytes; } uint64_t @@ -72,7 +78,7 @@ tcache_gc_postponed_event_wait(tsd_t *tsd) { uint64_t tcache_gc_dalloc_new_event_wait(tsd_t *tsd) { - return TCACHE_GC_INCR_BYTES; + return opt_tcache_gc_incr_bytes; } uint64_t diff --git a/test/stress/fill_flush.c b/test/stress/fill_flush.c index 6ea3ff96..a2db044d 100644 --- a/test/stress/fill_flush.c +++ b/test/stress/fill_flush.c @@ -69,7 +69,6 @@ TEST_BEGIN(test_array_vs_item_large) { } TEST_END - int main(void) { return test_no_reentrancy( test_array_vs_item_small,