1 #ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
2 #define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
3 
4 #include "jemalloc/internal/ql.h"
5 #include "jemalloc/internal/size_classes.h"
6 #include "jemalloc/internal/stats_tsd.h"
7 #include "jemalloc/internal/ticker.h"
8 
9 /*
10  * Read-only information associated with each element of tcache_t's tbins array
11  * is stored separately, mainly to reduce memory usage.
12  */
13 struct tcache_bin_info_s {
14 	unsigned	ncached_max;	/* Upper limit on ncached. */
15 };
16 
17 struct tcache_bin_s {
18 	low_water_t	low_water;	/* Min # cached since last GC. */
19 	uint32_t	ncached;	/* # of cached objects. */
20 	/*
21 	 * ncached and stats are both modified frequently.  Let's keep them
22 	 * close so that they have a higher chance of being on the same
23 	 * cacheline, thus less write-backs.
24 	 */
25 	tcache_bin_stats_t tstats;
26 	/*
27 	 * To make use of adjacent cacheline prefetch, the items in the avail
28 	 * stack goes to higher address for newer allocations.  avail points
29 	 * just above the available space, which means that
30 	 * avail[-ncached, ... -1] are available items and the lowest item will
31 	 * be allocated first.
32 	 */
33 	void		**avail;	/* Stack of available objects. */
34 };
35 
36 struct tcache_s {
37 	/* Data accessed frequently first: prof, ticker and small bins. */
38 	uint64_t	prof_accumbytes;/* Cleared after arena_prof_accum(). */
39 	ticker_t	gc_ticker;	/* Drives incremental GC. */
40 	/*
41 	 * The pointer stacks associated with tbins follow as a contiguous
42 	 * array.  During tcache initialization, the avail pointer in each
43 	 * element of tbins is initialized to point to the proper offset within
44 	 * this array.
45 	 */
46 	tcache_bin_t	tbins_small[NBINS];
47 	/* Data accessed less often below. */
48 	ql_elm(tcache_t) link;		/* Used for aggregating stats. */
49 	arena_t		*arena;		/* Associated arena. */
50 	szind_t		next_gc_bin;	/* Next bin to GC. */
51 	/* For small bins, fill (ncached_max >> lg_fill_div). */
52 	uint8_t		lg_fill_div[NBINS];
53 	tcache_bin_t	tbins_large[NSIZES-NBINS];
54 };
55 
56 /* Linkage for list of available (previously used) explicit tcache IDs. */
57 struct tcaches_s {
58 	union {
59 		tcache_t	*tcache;
60 		tcaches_t	*next;
61 	};
62 };
63 
64 #endif /* JEMALLOC_INTERNAL_TCACHE_STRUCTS_H */
65