Tunables (The GNU C Library)

## 39 Tunables ¶

Tunables are a feature in the GNU C Library that allows application authors and distribution maintainers to alter the runtime library behavior to match their workload. These are implemented as a set of switches that may be modified in different ways. The current default method to do this is via the `GLIBC_TUNABLES` environment variable by setting it to a string of colon-separated name=value pairs. For example, the following example enables `malloc` checking and sets the `malloc` trim threshold to 128 bytes:

    GLIBC_TUNABLES=glibc.malloc.trim_threshold=128:glibc.malloc.check=3
    export GLIBC_TUNABLES

Tunables are not part of the GNU C Library stable ABI, and they are subject to change or removal across releases. Additionally, the method to modify tunable values may change between releases and across distributions. It is possible to implement multiple ‘frontends’ for the tunables allowing distributions to choose their preferred method at build time.

Finally, the set of tunables available may vary between distributions as the tunables feature allows distributions to add their own tunables under their own namespace.

Passing `--list-tunables` to the dynamic loader to print all tunables with minimum and maximum values:

    $ /lib64/ld-linux-x86-64.so.2 --list-tunables
    glibc.rtld.nns: 0x4 (min: 0x1, max: 0x10)
    glibc.malloc.trim_threshold: 0x0 (min: 0x0, max: 0xffffffffffffffff)
    glibc.malloc.perturb: 0 (min: 0, max: 255)
    glibc.cpu.x86_shared_cache_size: 0x100000 (min: 0x0, max: 0xffffffffffffffff)
    glibc.pthread.rseq: 1 (min: 0, max: 1)
    glibc.cpu.prefer_map_32bit_exec: 0 (min: 0, max: 1)
    glibc.mem.tagging: 0 (min: 0, max: 255)
    glibc.malloc.hugetlb: 0x0 (min: 0x0, max: 0xffffffffffffffff)
    glibc.cpu.x86_rep_movsb_threshold: 0x2000 (min: 0x100, max: 0xffffffffffffffff)
    glibc.malloc.mxfast: 0x0 (min: 0x0, max: 0xffffffffffffffff)
    glibc.rtld.dynamic_sort: 2 (min: 1, max: 2)
    glibc.malloc.top_pad: 0x20000 (min: 0x0, max: 0xffffffffffffffff)
    glibc.cpu.x86_rep_stosb_threshold: 0x800 (min: 0x1, max: 0xffffffffffffffff)
    glibc.cpu.x86_non_temporal_threshold: 0xc0000 (min: 0x4040, max: 0xfffffffffffffff)
    glibc.cpu.x86_memset_non_temporal_threshold: 0xc0000 (min: 0x4040, max: 0xfffffffffffffff)
    glibc.cpu.x86_shstk:
    glibc.pthread.stack_cache_size: 0x2800000 (min: 0x0, max: 0xffffffffffffffff)
    glibc.malloc.mmap_max: 0 (min: 0, max: 2147483647)
    glibc.cpu.plt_rewrite: 0 (min: 0, max: 2)
    glibc.cpu.x86_ibt:
    glibc.cpu.hwcaps:
    glibc.malloc.arena_max: 0x0 (min: 0x1, max: 0xffffffffffffffff)
    glibc.malloc.mmap_threshold: 0x0 (min: 0x0, max: 0xffffffffffffffff)
    glibc.cpu.x86_data_cache_size: 0x8000 (min: 0x0, max: 0xffffffffffffffff)
    glibc.malloc.tcache_count: 0x0 (min: 0x0, max: 0xffffffffffffffff)
    glibc.malloc.arena_test: 0x0 (min: 0x1, max: 0xffffffffffffffff)
    glibc.pthread.mutex_spin_count: 100 (min: 0, max: 32767)
    glibc.rtld.optional_static_tls: 0x200 (min: 0x0, max: 0xffffffffffffffff)
    glibc.malloc.tcache_max: 0x0 (min: 0x0, max: 0xffffffffffffffff)
    glibc.malloc.check: 0 (min: 0, max: 3)
    glibc.elf.thp: 0 (min: 0, max: 1)