• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef JEMALLOC_INTERNAL_TCACHE_TYPES_H
2 #define JEMALLOC_INTERNAL_TCACHE_TYPES_H
3 
4 #include "jemalloc/internal/size_classes.h"
5 
6 typedef struct tcache_s tcache_t;
7 typedef struct tcaches_s tcaches_t;
8 
9 /*
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.
13  */
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
18 
19 /*
20  * Absolute minimum number of cache slots for each small bin.
21  */
22 #if defined(ANDROID_TCACHE_NSLOTS_SMALL_MIN)
23 #define TCACHE_NSLOTS_SMALL_MIN		ANDROID_TCACHE_NSLOTS_SMALL_MIN
24 #else
25 #define TCACHE_NSLOTS_SMALL_MIN		20
26 #endif
27 
28 /*
29  * Absolute maximum number of cache slots for each small bin in the thread
30  * cache.  This is an additional constraint beyond that imposed as: twice the
31  * number of regions per slab for this size class.
32  *
33  * This constant must be an even number.
34  */
35 #if defined(ANDROID_TCACHE_NSLOTS_SMALL_MAX)
36 #define TCACHE_NSLOTS_SMALL_MAX		ANDROID_TCACHE_NSLOTS_SMALL_MAX
37 #else
38 #define TCACHE_NSLOTS_SMALL_MAX		200
39 #endif
40 
41 /* Number of cache slots for large size classes. */
42 #if defined(ANDROID_TCACHE_NSLOTS_LARGE)
43 #define TCACHE_NSLOTS_LARGE		ANDROID_TCACHE_NSLOTS_LARGE
44 #else
45 #define TCACHE_NSLOTS_LARGE		20
46 #endif
47 
48 /* (1U << opt_lg_tcache_max) is used to compute tcache_maxclass. */
49 #if defined(ANDROID_LG_TCACHE_MAXCLASS_DEFAULT)
50 #define LG_TCACHE_MAXCLASS_DEFAULT	ANDROID_LG_TCACHE_MAXCLASS_DEFAULT
51 #else
52 #define LG_TCACHE_MAXCLASS_DEFAULT	15
53 #endif
54 
55 /*
56  * TCACHE_GC_SWEEP is the approximate number of allocation events between
57  * full GC sweeps.  Integer rounding may cause the actual number to be
58  * slightly higher, since GC is performed incrementally.
59  */
60 #define TCACHE_GC_SWEEP			8192
61 
62 /* Number of tcache allocation/deallocation events between incremental GCs. */
63 #define TCACHE_GC_INCR							\
64     ((TCACHE_GC_SWEEP / NBINS) + ((TCACHE_GC_SWEEP / NBINS == 0) ? 0 : 1))
65 
66 /* Used in TSD static initializer only. Real init in tcache_data_init(). */
67 #define TCACHE_ZERO_INITIALIZER {0}
68 
69 /* Used in TSD static initializer only. Will be initialized to opt_tcache. */
70 #define TCACHE_ENABLED_ZERO_INITIALIZER false
71 
72 #endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */
73