Tcache: Make incremental gc bytes configurable.

This commit is contained in:
David Goldblatt 2020-05-11 15:53:30 -07:00 committed by David Goldblatt
parent ec0b579563
commit d338dd45d7
6 changed files with 15 additions and 8 deletions

View File

@ -8,6 +8,7 @@ extern unsigned opt_tcache_nslots_small_min;
extern unsigned opt_tcache_nslots_small_max; extern unsigned opt_tcache_nslots_small_max;
extern unsigned opt_tcache_nslots_large; extern unsigned opt_tcache_nslots_large;
extern ssize_t opt_lg_tcache_shift; 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 * Number of tcache bins. There are SC_NBINS small-object bins, plus 0 or more

View File

@ -17,9 +17,6 @@ typedef struct tcaches_s tcaches_t;
#define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3) #define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3)
#define TCACHE_STATE_MAX TCACHE_STATE_PURGATORY #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(). */ /* Used in TSD static initializer only. Real init in tsd_tcache_data_init(). */
#define TCACHE_ZERO_INITIALIZER {0} #define TCACHE_ZERO_INITIALIZER {0}
#define TCACHE_SLOW_ZERO_INITIALIZER {0} #define TCACHE_SLOW_ZERO_INITIALIZER {0}

View File

@ -53,10 +53,10 @@ void tsd_te_init(tsd_t *tsd);
* E(event, (condition), is_alloc_event) * E(event, (condition), is_alloc_event)
*/ */
#define ITERATE_OVER_ALL_EVENTS \ #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(prof_sample, (config_prof && opt_prof), true) \
E(stats_interval, (opt_stats_interval >= 0), 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) \ #define E(event, condition_unused, is_alloc_event_unused) \
C(event##_event_wait) C(event##_event_wait)

View File

@ -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, CONF_HANDLE_UNSIGNED(opt_tcache_nslots_large,
"tcache_nslots_large", 1, 2048, "tcache_nslots_large", 1, 2048,
CONF_CHECK_MIN, CONF_CHECK_MAX, /* clip */ true) 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 * The runtime option of oversize_threshold remains

View File

@ -33,6 +33,12 @@ unsigned opt_tcache_nslots_large = 20;
*/ */
ssize_t opt_lg_tcache_nslots_mul = -1; 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; cache_bin_info_t *tcache_bin_info;
/* Total stack size required (per tcache). Include the padding above. */ /* Total stack size required (per tcache). Include the padding above. */
@ -62,7 +68,7 @@ tcache_salloc(tsdn_t *tsdn, const void *ptr) {
uint64_t uint64_t
tcache_gc_new_event_wait(tsd_t *tsd) { tcache_gc_new_event_wait(tsd_t *tsd) {
return TCACHE_GC_INCR_BYTES; return opt_tcache_gc_incr_bytes;
} }
uint64_t uint64_t
@ -72,7 +78,7 @@ tcache_gc_postponed_event_wait(tsd_t *tsd) {
uint64_t uint64_t
tcache_gc_dalloc_new_event_wait(tsd_t *tsd) { tcache_gc_dalloc_new_event_wait(tsd_t *tsd) {
return TCACHE_GC_INCR_BYTES; return opt_tcache_gc_incr_bytes;
} }
uint64_t uint64_t

View File

@ -69,7 +69,6 @@ TEST_BEGIN(test_array_vs_item_large) {
} }
TEST_END TEST_END
int main(void) { int main(void) {
return test_no_reentrancy( return test_no_reentrancy(
test_array_vs_item_small, test_array_vs_item_small,