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