pub fn default_threads_max(total_ram_bytes: u64) -> u64Expand description
Calculates system default for /proc/sys/kernel/threads-max from total RAM in bytes.
Per proc_sys_kernel(5), /proc/sys/kernel/threads-max:
“This file specifies the system-wide limit on the number of threads (tasks)
that can be created on the system.”
…
“If the thread structures would occupy too much (more than 1/8th) of the
available RAM pages, threads-max is reduced accordingly.”
Align with Linux, which budgets 16 KiB per thread stack regardless of the
system page size, limiting total thread stacks to 1/8th of available RAM and
clamping threads-max to [20, FUTEX_TID_MASK].