#980 Make the garbage collector run more often when under load
Reporter
Link Mauve
Owner
Nobody
Created
Updated
Stars
★ (1)
Tags
Status-WontFix
Priority-Medium
Type-Enhancement
Link Mauve
on
Description of feature:
Detect when memory usage is increasing too quickly and trigger a garbage collection at that moment, while decreasing the duration until the next collection.
Motivation: (Why?)
When Prosody is getting a lot of requests (typically during an attack), Lua’s memory usage is increasing a lot, and this memory is never freed, resulting in a way higher usage than expected until the next restart. This would trade some CPU time during the attack against a much better handling of memory in the long term.
Description of feature: Detect when memory usage is increasing too quickly and trigger a garbage collection at that moment, while decreasing the duration until the next collection. Motivation: (Why?) When Prosody is getting a lot of requests (typically during an attack), Lua’s memory usage is increasing a lot, and this memory is never freed, resulting in a way higher usage than expected until the next restart. This would trade some CPU time during the attack against a much better handling of memory in the long term.
First, try experimenting with the existing tunables that Lua exposes for its garbage collector. See https://www.lua.org/manual/5.1/manual.html#2.10 (for Lua 5.1) or https://www.lua.org/manual/5.2/manual.html#2.5 (for 5.2) This can be done from the config, eg by adding: collectgarbage("setpause", 120) If this isn't enough, then we can start thinking about other options.
ChangesDid you find any good parameters or are you still having issues?