1 #ifndef JEMALLOC_INTERNAL_TCACHE_TYPES_H
2 #define JEMALLOC_INTERNAL_TCACHE_TYPES_H
4 #include "jemalloc/internal/size_classes.h"
6 typedef struct tcache_s tcache_t;
7 typedef struct tcaches_s tcaches_t;
10 * tcache pointers close to NULL are used to encode state information that is
11 * used for two purposes: preventing thread caching on a per thread basis and
12 * cleaning up during thread shutdown.
14 #define TCACHE_STATE_DISABLED ((tcache_t *)(uintptr_t)1)
15 #define TCACHE_STATE_REINCARNATED ((tcache_t *)(uintptr_t)2)
16 #define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3)
17 #define TCACHE_STATE_MAX TCACHE_STATE_PURGATORY
20 * Absolute minimum number of cache slots for each small bin.
22 #define TCACHE_NSLOTS_SMALL_MIN 20
25 * Absolute maximum number of cache slots for each small bin in the thread
26 * cache. This is an additional constraint beyond that imposed as: twice the
27 * number of regions per slab for this size class.
29 * This constant must be an even number.
31 #define TCACHE_NSLOTS_SMALL_MAX 200
33 /* Number of cache slots for large size classes. */
34 #define TCACHE_NSLOTS_LARGE 20
36 /* (1U << opt_lg_tcache_max) is used to compute tcache_maxclass. */
37 #define LG_TCACHE_MAXCLASS_DEFAULT 15
40 * TCACHE_GC_SWEEP is the approximate number of allocation events between
41 * full GC sweeps. Integer rounding may cause the actual number to be
42 * slightly higher, since GC is performed incrementally.
44 #define TCACHE_GC_SWEEP 8192
46 /* Number of tcache allocation/deallocation events between incremental GCs. */
47 #define TCACHE_GC_INCR \
48 ((TCACHE_GC_SWEEP / NBINS) + ((TCACHE_GC_SWEEP / NBINS == 0) ? 0 : 1))
50 /* Used in TSD static initializer only. Real init in tcache_data_init(). */
51 #define TCACHE_ZERO_INITIALIZER {0}
53 /* Used in TSD static initializer only. Will be initialized to opt_tcache. */
54 #define TCACHE_ENABLED_ZERO_INITIALIZER false
56 #endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */