Blame jemalloc/include/jemalloc/internal/rtree_tsd.h

Packit 345191
#ifndef JEMALLOC_INTERNAL_RTREE_CTX_H
Packit 345191
#define JEMALLOC_INTERNAL_RTREE_CTX_H
Packit 345191
Packit 345191
/*
Packit 345191
 * Number of leafkey/leaf pairs to cache in L1 and L2 level respectively.  Each
Packit 345191
 * entry supports an entire leaf, so the cache hit rate is typically high even
Packit 345191
 * with a small number of entries.  In rare cases extent activity will straddle
Packit 345191
 * the boundary between two leaf nodes.  Furthermore, an arena may use a
Packit 345191
 * combination of dss and mmap.  Note that as memory usage grows past the amount
Packit 345191
 * that this cache can directly cover, the cache will become less effective if
Packit 345191
 * locality of reference is low, but the consequence is merely cache misses
Packit 345191
 * while traversing the tree nodes.
Packit 345191
 *
Packit 345191
 * The L1 direct mapped cache offers consistent and low cost on cache hit.
Packit 345191
 * However collision could affect hit rate negatively.  This is resolved by
Packit 345191
 * combining with a L2 LRU cache, which requires linear search and re-ordering
Packit 345191
 * on access but suffers no collision.  Note that, the cache will itself suffer
Packit 345191
 * cache misses if made overly large, plus the cost of linear search in the LRU
Packit 345191
 * cache.
Packit 345191
 */
Packit 345191
#define RTREE_CTX_LG_NCACHE 4
Packit 345191
#define RTREE_CTX_NCACHE (1 << RTREE_CTX_LG_NCACHE)
Packit 345191
#define RTREE_CTX_NCACHE_L2 8
Packit 345191
Packit 345191
/*
Packit 345191
 * Zero initializer required for tsd initialization only.  Proper initialization
Packit 345191
 * done via rtree_ctx_data_init().
Packit 345191
 */
Packit 345191
#define RTREE_CTX_ZERO_INITIALIZER {{{0, 0}}, {{0, 0}}}
Packit 345191
Packit 345191
Packit 345191
typedef struct rtree_leaf_elm_s rtree_leaf_elm_t;
Packit 345191
Packit 345191
typedef struct rtree_ctx_cache_elm_s rtree_ctx_cache_elm_t;
Packit 345191
struct rtree_ctx_cache_elm_s {
Packit 345191
	uintptr_t		leafkey;
Packit 345191
	rtree_leaf_elm_t	*leaf;
Packit 345191
};
Packit 345191
Packit 345191
typedef struct rtree_ctx_s rtree_ctx_t;
Packit 345191
struct rtree_ctx_s {
Packit 345191
	/* Direct mapped cache. */
Packit 345191
	rtree_ctx_cache_elm_t	cache[RTREE_CTX_NCACHE];
Packit 345191
	/* L2 LRU cache. */
Packit 345191
	rtree_ctx_cache_elm_t	l2_cache[RTREE_CTX_NCACHE_L2];
Packit 345191
};
Packit 345191
Packit 345191
void rtree_ctx_data_init(rtree_ctx_t *ctx);
Packit 345191
Packit 345191
#endif /* JEMALLOC_INTERNAL_RTREE_CTX_H */