Blame jemalloc/include/jemalloc/internal/tcache_types.h

Packit 345191
#ifndef JEMALLOC_INTERNAL_TCACHE_TYPES_H
Packit 345191
#define JEMALLOC_INTERNAL_TCACHE_TYPES_H
Packit 345191
Packit 345191
#include "jemalloc/internal/sc.h"
Packit 345191
Packit 345191
typedef struct tcache_s tcache_t;
Packit 345191
typedef struct tcaches_s tcaches_t;
Packit 345191
Packit 345191
/*
Packit 345191
 * tcache pointers close to NULL are used to encode state information that is
Packit 345191
 * used for two purposes: preventing thread caching on a per thread basis and
Packit 345191
 * cleaning up during thread shutdown.
Packit 345191
 */
Packit 345191
#define TCACHE_STATE_DISABLED		((tcache_t *)(uintptr_t)1)
Packit 345191
#define TCACHE_STATE_REINCARNATED	((tcache_t *)(uintptr_t)2)
Packit 345191
#define TCACHE_STATE_PURGATORY		((tcache_t *)(uintptr_t)3)
Packit 345191
#define TCACHE_STATE_MAX		TCACHE_STATE_PURGATORY
Packit 345191
Packit 345191
/*
Packit 345191
 * Absolute minimum number of cache slots for each small bin.
Packit 345191
 */
Packit 345191
#define TCACHE_NSLOTS_SMALL_MIN		20
Packit 345191
Packit 345191
/*
Packit 345191
 * Absolute maximum number of cache slots for each small bin in the thread
Packit 345191
 * cache.  This is an additional constraint beyond that imposed as: twice the
Packit 345191
 * number of regions per slab for this size class.
Packit 345191
 *
Packit 345191
 * This constant must be an even number.
Packit 345191
 */
Packit 345191
#define TCACHE_NSLOTS_SMALL_MAX		200
Packit 345191
Packit 345191
/* Number of cache slots for large size classes. */
Packit 345191
#define TCACHE_NSLOTS_LARGE		20
Packit 345191
Packit 345191
/* (1U << opt_lg_tcache_max) is used to compute tcache_maxclass. */
Packit 345191
#define LG_TCACHE_MAXCLASS_DEFAULT	15
Packit 345191
Packit 345191
/*
Packit 345191
 * TCACHE_GC_SWEEP is the approximate number of allocation events between
Packit 345191
 * full GC sweeps.  Integer rounding may cause the actual number to be
Packit 345191
 * slightly higher, since GC is performed incrementally.
Packit 345191
 */
Packit 345191
#define TCACHE_GC_SWEEP			8192
Packit 345191
Packit 345191
/* Number of tcache allocation/deallocation events between incremental GCs. */
Packit 345191
#define TCACHE_GC_INCR							\
Packit 345191
    ((TCACHE_GC_SWEEP / SC_NBINS) + ((TCACHE_GC_SWEEP / SC_NBINS == 0) ? 0 : 1))
Packit 345191
Packit 345191
/* Used in TSD static initializer only. Real init in tcache_data_init(). */
Packit 345191
#define TCACHE_ZERO_INITIALIZER {0}
Packit 345191
Packit 345191
/* Used in TSD static initializer only. Will be initialized to opt_tcache. */
Packit 345191
#define TCACHE_ENABLED_ZERO_INITIALIZER false
Packit 345191
Packit 345191
/* Used for explicit tcache only. Means flushed but not destroyed. */
Packit 345191
#define TCACHES_ELM_NEED_REINIT ((tcache_t *)(uintptr_t)1)
Packit 345191
Packit 345191
#endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */