]> git.proxmox.com Git - proxmox-backup.git/blob - pbs-tools/src/lib.rs
ui: garbage-collection: use different state-id for global and per-datastore view
[proxmox-backup.git] / pbs-tools / src / lib.rs
1 pub mod cert;
2 pub mod crypt_config;
3 pub mod format;
4 pub mod json;
5 pub mod lru_cache;
6 pub mod nom;
7 pub mod sha;
8
9 pub mod async_lru_cache;
10
11 /// Set MMAP_THRESHOLD to a fixed value (128 KiB)
12 ///
13 /// This avoids the "dynamic" mmap-treshold logic from glibc's malloc, which seems misguided and
14 /// effectively avoids using mmap for all allocations smaller than 32 MiB. Which, in combination
15 /// with the allocation pattern from our/tokio's complex async machinery, resulted in very large
16 /// RSS sizes due to defragmentation and long-living (smaller) allocation on top of the heap
17 /// avoiding that the (big) now free'd allocations below couldn't get given back to the OS. This is
18 /// not an issue with mmap'd memory chunks, those can be given back at any time.
19 ///
20 /// Lowering effective MMAP threshold to 128 KiB allows freeing up memory to the OS better and with
21 /// lower latency, which reduces the peak *and* average RSS size by an order of magnitude when
22 /// running backup jobs. We measured a reduction by a factor of 10-20 in experiments and see much
23 /// less erratic behavior in the overall's runtime RSS size.
24 pub fn setup_libc_malloc_opts() {
25 unsafe {
26 libc::mallopt(libc::M_MMAP_THRESHOLD, 4096 * 32);
27 }
28 }