]> git.ipfire.org Git - thirdparty/systemd.git/commit
fileio: start with 4k buffer for procfs
authorAnita Zhang <the.anitazha@gmail.com>
Tue, 14 Sep 2021 23:33:10 +0000 (16:33 -0700)
committerLennart Poettering <lennart@poettering.net>
Thu, 16 Sep 2021 09:31:29 +0000 (11:31 +0200)
commit5aaa55d841249f057fd69e50cf12a52e9781a6ce
treecb92d6b32b1c1a60929d6529abc20176bd8c2a9a
parent1dcd91ad11526f3595ba48bac36c74b0e3cdb203
fileio: start with 4k buffer for procfs

There's a very gradual increase of anonymous memory in systemd-journald that
blames to 2ac67221bb6270f0fbe7cbd0076653832cd49de2.

systemd-journald makes many calls to read /proc/PID/cmdline and
/proc/PID/status, both of which tend to be well under 4K. However the
combination of allocating 4M read buffers, then using `realloc()` to
shrink the buffer in `read_virtual_file()` appears to be creating
fragmentation in the heap (when combined with the other allocations
systemd-journald is doing).

To help mitigate this, try reading /proc with a 4K buffer as
`read_virtual_file()` did before 2ac67221bb6270f0fbe7cbd0076653832cd49de2.
If it isn't big enough then try again with the larger buffers.
src/basic/fileio.c