1#ifndef JEMALLOC_INTERNAL_SEC_OPTS_H
2#define JEMALLOC_INTERNAL_SEC_OPTS_H
3
4/*
5 * The configuration settings used by an sec_t. Morally, this is part of the
6 * SEC interface, but we put it here for header-ordering reasons.
7 */
8
9typedef struct sec_opts_s sec_opts_t;
10struct sec_opts_s {
11 /*
12 * We don't necessarily always use all the shards; requests are
13 * distributed across shards [0, nshards - 1).
14 */
15 size_t nshards;
16 /*
17 * We'll automatically refuse to cache any objects in this sec if
18 * they're larger than max_alloc bytes, instead forwarding such objects
19 * directly to the fallback.
20 */
21 size_t max_alloc;
22 /*
23 * Exceeding this amount of cached extents in a shard causes us to start
24 * flushing bins in that shard until we fall below bytes_after_flush.
25 */
26 size_t max_bytes;
27 /*
28 * The number of bytes (in all bins) we flush down to when we exceed
29 * bytes_cur. We want this to be less than bytes_cur, because
30 * otherwise we could get into situations where a shard undergoing
31 * net-deallocation keeps bytes_cur very near to max_bytes, so that
32 * most deallocations get immediately forwarded to the underlying PAI
33 * implementation, defeating the point of the SEC.
34 */
35 size_t bytes_after_flush;
36 /*
37 * When we can't satisfy an allocation out of the SEC because there are
38 * no available ones cached, we allocate multiple of that size out of
39 * the fallback allocator. Eventually we might want to do something
40 * cleverer, but for now we just grab a fixed number.
41 */
42 size_t batch_fill_extra;
43};
44
45#define SEC_OPTS_DEFAULT { \
46 /* nshards */ \
47 4, \
48 /* max_alloc */ \
49 (32 * 1024) < PAGE ? PAGE : (32 * 1024), \
50 /* max_bytes */ \
51 256 * 1024, \
52 /* bytes_after_flush */ \
53 128 * 1024, \
54 /* batch_fill_extra */ \
55 0 \
56}
57
58
59#endif /* JEMALLOC_INTERNAL_SEC_OPTS_H */
60