[OpenSIPS-Devel] [OpenSIPS/opensips] f91a4a: F_MALLOC: Add LHS coalescing on free() operations
Liviu Chircu
noreply at github.com
Wed Apr 19 13:23:29 UTC 2023
Branch: refs/heads/3.2
Home: https://github.com/OpenSIPS/opensips
Commit: f91a4aa0c8c7e94c7a4cde53a508c88a21161084
https://github.com/OpenSIPS/opensips/commit/f91a4aa0c8c7e94c7a4cde53a508c88a21161084
Author: Liviu Chircu <liviu at opensips.org>
Date: 2023-04-19 (Wed, 19 Apr 2023)
Changed paths:
M mem/f_malloc.c
M mem/f_malloc.h
M mem/f_malloc_dyn.h
Log Message:
-----------
F_MALLOC: Add LHS coalescing on free() operations
This is a continuation/rework of commit fb9a3777, which intended to
address the de-fragmentation issues where performance would drop.
Unfortunately, there were still memory allocation / releasing patterns
which still lead to heavy fragmentation. For example, an MI "dlg_list"
command, which allocates fragments from Left -> Right as the dialog list
is walked:
Chunk-1 Chunk-2 Chunk-3 ... Chunk-N
After building the MI output, the chunks were also freed Left -> Right.
Due to the former allocator logic of RHS-only coalescing, the coalescing
would never happen! In some cases, this could lead to fragmentation of
an indefinite amount of memory, given enough time (e.g., even 8 GB PKG).
This patch adds LHS coalescing to F_MALLOC, such that when "Chunk-2" is
freed, in the above example, the allocator tries to merge it with both
"Chunk-1" and "Chunk-3" before exiting the free() function (depending on
the state of chunks 1 and 3, this could mean 0, 1 or 2 coalescings).
This F_MALLOC patch was stress-tested using the mem/test/ testing suite.
Many thanks to @fedkis and @ankogan for helping troubleshoot the issue
and also test the current version of this patch!
Fixes #2726
(cherry picked from commit bdaaf60b2c42681da70f095468c2df1b8dfa8c3e)
More information about the Devel
mailing list