Blame jemalloc/include/jemalloc/internal/tcache_structs.h

Packit 345191
#ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
Packit 345191
#define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
Packit 345191
Packit 345191
#include "jemalloc/internal/cache_bin.h"
Packit 345191
#include "jemalloc/internal/ql.h"
Packit 345191
#include "jemalloc/internal/sc.h"
Packit 345191
#include "jemalloc/internal/ticker.h"
Packit 345191
#include "jemalloc/internal/tsd_types.h"
Packit 345191
Packit 345191
/* Various uses of this struct need it to be a named type. */
Packit 345191
typedef ql_elm(tsd_t) tsd_link_t;
Packit 345191
Packit 345191
struct tcache_s {
Packit 345191
	/*
Packit 345191
	 * To minimize our cache-footprint, we put the frequently accessed data
Packit 345191
	 * together at the start of this struct.
Packit 345191
	 */
Packit 345191
Packit 345191
	/* Cleared after arena_prof_accum(). */
Packit 345191
	uint64_t	prof_accumbytes;
Packit 345191
	/* Drives incremental GC. */
Packit 345191
	ticker_t	gc_ticker;
Packit 345191
	/*
Packit 345191
	 * The pointer stacks associated with bins follow as a contiguous array.
Packit 345191
	 * During tcache initialization, the avail pointer in each element of
Packit 345191
	 * tbins is initialized to point to the proper offset within this array.
Packit 345191
	 */
Packit 345191
	cache_bin_t	bins_small[SC_NBINS];
Packit 345191
Packit 345191
	/*
Packit 345191
	 * This data is less hot; we can be a little less careful with our
Packit 345191
	 * footprint here.
Packit 345191
	 */
Packit 345191
	/* Lets us track all the tcaches in an arena. */
Packit 345191
	ql_elm(tcache_t) link;
Packit 345191
Packit 345191
	/* Logically scoped to tsd, but put here for cache layout reasons. */
Packit 345191
	ql_elm(tsd_t) tsd_link;
Packit 345191
	bool in_hook;
Packit 345191
Packit 345191
	/*
Packit 345191
	 * The descriptor lets the arena find our cache bins without seeing the
Packit 345191
	 * tcache definition.  This enables arenas to aggregate stats across
Packit 345191
	 * tcaches without having a tcache dependency.
Packit 345191
	 */
Packit 345191
	cache_bin_array_descriptor_t cache_bin_array_descriptor;
Packit 345191
Packit 345191
	/* The arena this tcache is associated with. */
Packit 345191
	arena_t		*arena;
Packit 345191
	/* Next bin to GC. */
Packit 345191
	szind_t		next_gc_bin;
Packit 345191
	/* For small bins, fill (ncached_max >> lg_fill_div). */
Packit 345191
	uint8_t		lg_fill_div[SC_NBINS];
Packit 345191
	/*
Packit 345191
	 * We put the cache bins for large size classes at the end of the
Packit 345191
	 * struct, since some of them might not get used.  This might end up
Packit 345191
	 * letting us avoid touching an extra page if we don't have to.
Packit 345191
	 */
Packit 345191
	cache_bin_t	bins_large[SC_NSIZES-SC_NBINS];
Packit 345191
};
Packit 345191
Packit 345191
/* Linkage for list of available (previously used) explicit tcache IDs. */
Packit 345191
struct tcaches_s {
Packit 345191
	union {
Packit 345191
		tcache_t	*tcache;
Packit 345191
		tcaches_t	*next;
Packit 345191
	};
Packit 345191
};
Packit 345191
Packit 345191
#endif /* JEMALLOC_INTERNAL_TCACHE_STRUCTS_H */