0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-17 16:48:43 +00:00
bird/sysdep
Maria Matejka 973aa37e1e Fix memory pre-allocation
When BIRD has no free memory mapped, it allocates several pages in
advance just to be sure that there is some memory available if needed.
This hysteresis tactics works quite well to reduce memory ping-ping with
kernel.

Yet it had a subtle bug: this pre-allocation didn't take a memory
coldlist into account, therefore requesting new pages from kernel even
in cases when there were other pages available. This led to slow memory
bloating.

To demonstrate this behavior fast enough to be seen well, you may:
  * temporarily set the values in sysdep/unix/alloc.c as follows to
    exacerbate the issue:
      #define KEEP_PAGES_MAIN_MAX    4096
      #define KEEP_PAGES_MAIN_MIN    1000
      #define CLEANUP_PAGES_BULK     4096
  * create a config file with several millions of static routes
  * periodically disable all static protocols and then reload config
  * log memory consumption

This should give you a steady growth rate of about 16kB per cycle. If
you don't set the values this high, the issue happens much more slowly,
yet after 14 days of running, you are going to see an OOM kill.

After this fix, pre-allocation uses the memory coldlist to get some hot
pages and the same test as described here gets you a perfectly stable
constant memory consumption (after some initial wobbling).

Thanks to NIX-CZ for reporting and helping to investigate this issue.
Thanks to Santiago for finding the cause in the code.
2023-01-18 09:39:45 +01:00
..
bsd BSD: Use ip_mreqn on FreeBSD 12.1+ and OpenBSD 6.9+ 2022-12-18 20:23:46 +01:00
bsd-netlink Netlink: move OS-specific headers and defines to sysdep 2022-12-16 19:21:51 +01:00
cf Netlink: move OS-specific headers and defines to sysdep 2022-12-16 19:21:51 +01:00
linux Netlink: move OS-specific headers and defines to sysdep 2022-12-16 19:21:51 +01:00
unix Fix memory pre-allocation 2023-01-18 09:39:45 +01:00
config.h NEWS and version update 2022-12-11 17:28:14 +01:00
Doc Doc: Rename code documentation files back to Doc 2018-12-14 02:03:42 +01:00
sysdep.sgml Spelling fixes to progdoc. 2000-06-07 12:29:08 +00:00