Expand description
The setup of the server process before it serves: umask, OOM score, open files limit, malloc and transparent huge pages, the standard streams and the descriptors it inherited, its working directory and the subreaper flag, and giving the runtime calls the OOM score, huge pages setting and open files limits the server started with.
ConstantsΒ§
- MALLOC_
ARENAS π - The most malloc arenas of the server. glibc gives every thread an arena
of its own, up to eight per CPU, and on AArch64 it backs them with 2 MiB
transparent huge pages by default, so each costs up to 2 MiB resident. The
runtime, which also runs the RPC
LocalSet, runs on one thread, the others only serve short blocking work, so one arena is enough, the per thread caches of the allocator absorb most of the contention. - MALLOC_
THRESHOLD π - The size from which on glibc maps every allocation on its own, which goes back to the kernel once freed, and the free memory at the top of the heap from which on glibc returns it. Both are the defaults of glibc, which raises them to the size of every mapped allocation that gets freed, up to 32 and 64 MiB. After an exec_sync with a large output, up to 16 MiB per pipe which get copied into the response, the allocations of that size would stay in the heap then and keep it resident. Setting them turns that off.
- OOM_
SCORE_ πADJ - The OOM score adjustment of the server.
StaticsΒ§
- INHERITED_
NOFILE π - The soft and hard limit of open files the server started with, if it
raised the soft one, see
raise_nofile_limit. - INHERITED_
OOM_ πSCORE - The OOM score adjustment the server started with, see
reset_inherited. - THP_
DISABLED π - Whether the server turned transparent huge pages off for itself, which
the processes it runs must not inherit, see
disable_thp.
FunctionsΒ§
- close_
inherited_ πfds - Close file descriptors inherited from whatever started us.
- configure_
malloc π - Limit the malloc arenas of the server, see
MALLOC_ARENAS, and fix the thresholds of glibc, seeMALLOC_THRESHOLD. Runs before the fork, while the process has a single thread. The runtimes and containers keep the defaults, an exec starts their allocator anew. - disable_
thp π - Turn transparent huge pages off for the process, as early as possible. On AArch64 glibc asks for them for its heap by default, so the first growth of the heap beyond a 2 MiB boundary costs 2 MiB resident, which a server per pod does not need. mallopt cannot turn that off, and the tunable which can takes effect only from the start of the process. Huge pages which were already allocated stay.
- inherited_
fds π - Every open descriptor above stderr. Split out from
close_inherited_fdsso it can be tested without closing the test runnerβs own descriptors. - raise_
nofile_ πlimit - Raise the soft limit of open files to the hard one. The server holds the
pipes, log files, pidfds and sockets of every container of a pod and the
sessions of the streaming server, while Go programs like CRI-O start it
with the soft limit they started with, often 1024. The runtimes get the
limits the server started with, see
reset_inherited. - redirect_
stdio π - Like a daemon, do not keep the standard streams of the caller, like the
file the Go client reads the launch errors from, see
startServerinpkg/client. The processes the server starts, like the runtimes, would write into it otherwise. Only the stdout log driver writes to them. - reset_
inherited π - Give a child the OOM score adjustment, the transparent huge pages setting
and the open files limits the server started with instead of its own, see
save_oom_score,disable_thpandraise_nofile_limit. The runtimes pass them on to the container processes, an exec would be the last process the kernel picks otherwise. conmon resets the OOM score of its runtime the same way. Add it after the other pre_exec hooks, those run in order and may need the raised limit. - restore_
nofile π - Set the open files limits of the process, if any, async signal safe for a pre_exec hook. A failure keeps the ones of the server.
- save_
oom_ πscore - Remember the OOM score adjustment the server started with, before it
protects itself with
set_oom_score. - set_
default_ πumask - Set the default umask.
- set_
oom_ πscore - Adjust the OOM score of the server, best effort without the privileges to lower it.
- set_
oom_ πscore_ at - set_
up_ πprocess - Set up the process before it forks: remember the OOM score and raise the
open files limit for the runtimes, configure malloc and protect the
server from the OOM killer. The server keeps the C locale, unlike conmon,
so that the errors it returns to CRI-O do not depend on the environment.
The umask is set before the configuration prepares the runtime
directories, see
crate::run. - set_
up_ πserving - Set up the process to serve, once the logging is: do not keep the working
directory of the caller busy, like a mount which then cannot be unmounted
(the paths of the configuration are absolute, see
Config::make_absolute, and so are the ones of the requests), and make the container processes get reparented to the server once their runtime exits.