0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-14 15:18:44 +00:00
bird/sysdep/unix
Maria Matejka 95b528e129 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.
2024-05-30 12:30:00 +02:00
..
alloc.c Fix memory pre-allocation 2024-05-30 12:30:00 +02:00
config.Y Log: Do not open logfiles when parse-and-exit option is active 2020-06-03 14:59:20 +02:00
Doc Doc: Rename code documentation files back to Doc 2018-12-14 02:03:42 +01:00
endian.h OpenBSD port related changes. 2009-05-11 01:32:49 +02:00
io.c Log message before aborting 2024-05-30 12:30:00 +02:00
krt.c BSD: Fix krt socket code w.r.t. rte/rta changes 2024-05-30 12:29:59 +02:00
krt.h Merge branch 'master' into backport 2022-07-27 00:47:24 +02:00
krt.Y Dynamic attributes definition split whether it is bitmask or not. 2019-07-03 00:00:11 +02:00
log.c Log message before aborting 2024-05-30 12:30:00 +02:00
main.c CLI: Fix for long-lived sessions during high loads 2024-05-30 12:29:59 +02:00
Makefile Simplified the protocol hookup code in Makefiles 2022-08-18 22:07:30 +02:00
random.c sysdep: Add wrapper to get random bytes - update 2021-06-06 16:26:06 +02:00
unix.h BGP: Add support for BGP hostname capability 2021-02-10 16:53:57 +01:00