]>
Commit | Line | Data |
---|---|---|
f035d41b XL |
1 | //! `jemalloc`'s run-time configuration. |
2 | //! | |
3 | //! These settings are controlled by the `MALLOC_CONF` environment variable. | |
4 | ||
5 | option! { | |
6 | abort[ str: b"opt.abort\0", non_str: 2 ] => bool | | |
7 | ops: r | | |
8 | docs: | |
9 | /// Whether `jemalloc` calls `abort(3)` on most warnings. | |
10 | /// | |
11 | /// This is disabled by default unless `--enable-debug` was specified during | |
12 | /// build configuration. | |
13 | /// | |
14 | /// # Examples | |
15 | /// | |
16 | /// ``` | |
17 | /// # extern crate jemallocator; | |
18 | /// # extern crate jemalloc_ctl; | |
19 | /// # | |
20 | /// # #[global_allocator] | |
21 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
22 | /// # | |
23 | /// # fn main() { | |
24 | /// use jemalloc_ctl::opt; | |
25 | /// let abort = opt::abort::mib().unwrap(); | |
26 | /// println!("abort on warning: {}", abort.read().unwrap()); | |
27 | /// # } | |
28 | /// ``` | |
29 | mib_docs: /// See [`abort`]. | |
30 | } | |
31 | ||
32 | option! { | |
33 | dss[ str: b"opt.dss\0", str: 2 ] => &'static str | | |
34 | ops: r | | |
35 | docs: | |
36 | /// The `dss` (`sbrk(2)`) allocation precedence as related to `mmap(2)` | |
37 | /// allocation. | |
38 | /// | |
39 | /// The following settings are supported if `sbrk(2)` is supported by the | |
40 | /// operating system: "disabled", "primary", and "secondary"; otherwise only | |
41 | /// "disabled" is supported. The default is "secondary" if `sbrk(2)` is | |
42 | /// supported by the operating system; "disabled" otherwise. | |
43 | /// | |
44 | /// # Examples | |
45 | /// | |
46 | /// ``` | |
47 | /// # extern crate jemallocator; | |
48 | /// # extern crate jemalloc_ctl; | |
49 | /// # | |
50 | /// # #[global_allocator] | |
51 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
52 | /// # | |
53 | /// # fn main() { | |
54 | /// use jemalloc_ctl::opt; | |
55 | /// let dss = opt::dss::read().unwrap(); | |
56 | /// println!("dss priority: {}", dss); | |
57 | /// # } | |
58 | /// ``` | |
59 | mib_docs: /// See [`dss`]. | |
60 | } | |
61 | ||
62 | option! { | |
63 | narenas[ str: b"opt.narenas\0", non_str: 2 ] => libc::c_uint | | |
64 | ops: r | | |
65 | docs: | |
66 | /// Maximum number of arenas to use for automatic multiplexing of threads | |
67 | /// and arenas. | |
68 | /// | |
69 | /// The default is four times the number of CPUs, or one if there is a | |
70 | /// single CPU. | |
71 | /// | |
72 | /// # Examples | |
73 | /// | |
74 | /// ``` | |
75 | /// # extern crate jemallocator; | |
76 | /// # extern crate jemalloc_ctl; | |
77 | /// # | |
78 | /// # #[global_allocator] | |
79 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
80 | /// # | |
81 | /// # fn main() { | |
82 | /// use jemalloc_ctl::opt; | |
83 | /// let narenas = opt::narenas::read().unwrap(); | |
84 | /// println!("number of arenas: {}", narenas); | |
85 | /// # } | |
86 | /// ``` | |
87 | mib_docs: /// See [`narenas`]. | |
88 | } | |
89 | ||
90 | option! { | |
91 | junk[ str: b"opt.junk\0", str: 2 ] => &'static str | | |
92 | ops: r | | |
93 | docs: | |
94 | /// `jemalloc`'s junk filling mode. | |
95 | /// | |
96 | /// Requires `--enable-fill` to have been specified during build | |
97 | /// configuration. | |
98 | /// | |
99 | /// If set to "alloc", each byte of uninitialized allocated memory will be | |
100 | /// set to `0x5a`. If set to "free", each byte of deallocated memory will be set | |
101 | /// to `0x5a`. If set to "true", both allocated and deallocated memory will be | |
102 | /// initialized, and if set to "false" junk filling will be disabled. This is | |
103 | /// intended for debugging and will impact performance negatively. | |
104 | /// | |
105 | /// The default is "false", unless `--enable-debug` was specified during | |
106 | /// build configuration, in | |
107 | /// which case the default is "true". | |
108 | /// | |
109 | /// # Examples | |
110 | /// | |
111 | /// ``` | |
112 | /// # extern crate jemallocator; | |
113 | /// # extern crate jemalloc_ctl; | |
114 | /// # | |
115 | /// # #[global_allocator] | |
116 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
117 | /// # | |
118 | /// # fn main() { | |
119 | /// use jemalloc_ctl::opt; | |
120 | /// let junk = opt::junk::read().unwrap(); | |
121 | /// println!("junk filling: {}", junk); | |
122 | /// # } | |
123 | /// ``` | |
124 | mib_docs: /// See [`junk`]. | |
125 | } | |
126 | ||
127 | option! { | |
128 | zero[ str: b"opt.zero\0", non_str: 2 ] => bool | | |
129 | ops: r | | |
130 | docs: | |
131 | /// `jemalloc`'s zeroing behavior. | |
132 | /// | |
133 | /// Requires `--enable-fill` to have been specified during build | |
134 | /// configuration. | |
135 | /// | |
136 | /// If enabled, `jemalloc` will initialize each byte of uninitialized | |
137 | /// allocated memory to 0. This is intended for debugging and will impact | |
138 | /// performance negatively. It is disabled by default. | |
139 | /// | |
140 | /// # Examples | |
141 | /// | |
142 | /// ``` | |
143 | /// # extern crate jemallocator; | |
144 | /// # extern crate jemalloc_ctl; | |
145 | /// # | |
146 | /// # #[global_allocator] | |
147 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
148 | /// # | |
149 | /// # fn main() { | |
150 | /// use jemalloc_ctl::opt; | |
151 | /// let zero = opt::zero::read().unwrap(); | |
152 | /// println!("zeroing: {}", zero); | |
153 | /// # } | |
154 | /// ``` | |
155 | mib_docs: /// See [`zero`]. | |
156 | } | |
157 | ||
158 | option! { | |
159 | tcache[ str: b"opt.tcache\0", non_str: 2 ] => bool | | |
160 | ops: r | | |
161 | docs: | |
162 | /// Thread-local allocation caching behavior. | |
163 | /// | |
164 | /// Thread-specific caching allows many allocations to be satisfied without | |
165 | /// performing any thread synchronization, at the cost of increased memory | |
166 | /// use. This is enabled by default. | |
167 | /// | |
168 | /// # Examples | |
169 | /// | |
170 | /// ``` | |
171 | /// # extern crate jemallocator; | |
172 | /// # extern crate jemalloc_ctl; | |
173 | /// # | |
174 | /// # #[global_allocator] | |
175 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
176 | /// # | |
177 | /// # fn main() { | |
178 | /// use jemalloc_ctl::opt; | |
179 | /// let tcache = opt::tcache::read().unwrap(); | |
180 | /// println!("thread-local caching: {}", tcache); | |
181 | /// # } | |
182 | /// ``` | |
183 | mib_docs: /// See [`tcache`]. | |
184 | } | |
185 | ||
186 | option! { | |
187 | lg_tcache_max[ str: b"opt.lg_tcache_max\0", non_str: 2 ] => libc::size_t | | |
188 | ops: r | | |
189 | docs: | |
190 | /// Maximum size class (log base 2) to cache in the thread-specific cache | |
191 | /// (`tcache`). | |
192 | /// | |
193 | /// At a minimum, all small size classes are cached, and at a maximum all | |
194 | /// large size classes are cached. The default maximum is 32 KiB (2^15). | |
195 | /// | |
196 | /// # Examples | |
197 | /// | |
198 | /// ``` | |
199 | /// # extern crate jemallocator; | |
200 | /// # extern crate jemalloc_ctl; | |
201 | /// # | |
202 | /// # #[global_allocator] | |
203 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
204 | /// # | |
205 | /// # fn main() { | |
206 | /// use jemalloc_ctl::opt; | |
207 | /// let lg_tcache_max = opt::lg_tcache_max::read().unwrap(); | |
208 | /// println!("max cached allocation size: {}", 1 << lg_tcache_max); | |
209 | /// # } | |
210 | /// ``` | |
211 | mib_docs: /// See [`lg_tcache_max`]. | |
212 | } | |
213 | ||
214 | option! { | |
215 | background_thread[ str: b"opt.background_thread\0", non_str: 2 ] => bool | | |
216 | ops: r | | |
217 | docs: | |
218 | /// `jemalloc`'s default initialization behavior for background threads. | |
219 | /// | |
220 | /// `jemalloc` automatically spawns background worker threads on | |
221 | /// initialization (first `jemalloc` call) if this option is enabled. By | |
222 | /// default this option is disabled - `malloc_conf=background_thread:true` | |
223 | /// changes its default. | |
224 | /// | |
225 | /// # Examples | |
226 | /// | |
227 | /// ``` | |
228 | /// # extern crate jemallocator; | |
229 | /// # extern crate jemalloc_ctl; | |
230 | /// # | |
231 | /// # #[global_allocator] | |
232 | /// # static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | |
233 | /// # | |
234 | /// # fn main() { | |
235 | /// use jemalloc_ctl::opt; | |
236 | /// let background_thread = opt::background_thread::read().unwrap(); | |
237 | /// println!("background threads since initialization: {}", background_thread); | |
238 | /// # } | |
239 | /// ``` | |
240 | mib_docs: /// See [`background_thread`]. | |
241 | } |