Cumulative stats, auto-disable 14044 workaround

If the fix for this gets merged, it will cause IDs to
just keep increasing until they wrap around, which
would eat up memory.  Detect this before it
becomes critical, and disable the pooling hack
permanently (for this session) in that case.
This commit is contained in:
Aaron Suen 2023-11-30 23:03:47 -05:00
parent 0af6670f28
commit 8d257696e1
2 changed files with 9 additions and 4 deletions

View File

@ -60,6 +60,7 @@ NEW MT RELEASE PROCESS
AFTER 5.6 EOS:
AFTER 5.7 EOS:
- Remove compat_14044 workaround, if it's been fixed upstream.
........................................................................
========================================================================

View File

@ -8,6 +8,8 @@ local string_format
local function createpool(poolname)
local pool = {}
local disabled
local reused = 0
local inserted = 0
local removed = 0
@ -16,15 +18,17 @@ local function createpool(poolname)
nodecore.log("info", string_format(
"%s resource pool: %d inserted, %d reused, %d removed",
poolname, inserted, reused, removed))
inserted = 0
reused = 0
removed = 0
if inserted >= 1000 and reused == 0 then
disabled = true
pool = {}
return
end
minetest.after(60, rpt)
end
minetest.after(60, rpt)
local function upsert(id, ...)
if not id then return id, ... end
if disabled or not id then return id, ... end
local found = pool[id]
if found then
found.id = nil