Hello Henning,
Thank you for your quick response !
I do not have any error messages.
Shared memory allocation and freeing is done exclusively by the RPC process.
The workers only read that memory (and only the memory that is *not* being allocated or
freed by the RPC process).
I've looked at the different shared memory managers as you suggested.
First, « tlsf » does not work : Kamailio crashes on startup with « -x tlsf ».
A comparison of « qm » (default) and « fm » :
With « fm », the loading time is reduced by 25%.
The freeing is also much faster (maybe 4 times faster).
And I do not notice the performances issues (that I can reproduce when using « qm »).
But maybe this is because I do not have enough data on my test environment. I'll have
to test this with the real data.
But these first results with « fm » look promising ! :)
Could you maybe explain to me the main differences between the 3 shared memory managers ?
and why is « qm » the default ?
Also, do you have an idea why « tlsf » makes Kamailio crash ? (does anyone use « tlsf »
?)
Thanks again.
Regards,
Nicolas.
De : Henning Westerholt <hw(a)gilawa.com>
Envoyé : jeudi 19 janvier 2023 08:28
À : Kamailio (SER) - Users Mailing List
Cc : Chaigneau, Nicolas; sr-dev(a)lists.kamailio.org
Objet : RE: Performances issue when freeing shared memory in custom module (Kamailio
5.5.2)
This mail has been sent from an external source
Hello,
(Adding sr-dev to CC)
This looks indeed a bit strange. Do you get any error messages in the log? In which
process you are freeing the memory, one of the worker processes or the RPC process?
You could also try to use another memory manager to see if you get better performance.
There is a command line parameter to choose one during startup.
Cheers,
Henning
--
Henning Westerholt -
https://skalatan.de/blog/
Kamailio services -
https://gilawa.com<https://gilawa.com/>
From: Chaigneau, Nicolas
<nicolas.chaigneau@capgemini.com<mailto:nicolas.chaigneau@capgemini.com>>
Sent: Wednesday, January 18, 2023 6:49 PM
To: Kamailio (SER) - Users Mailing List
<sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org>>
Subject: [SR-Users] Performances issue when freeing shared memory in custom module
(Kamailio 5.5.2)
Hello,
I'm encountering performance issues with Kamailio (5.5.2).
I'm using a custom Kamailio module that loads routing data in memory, using Kamailio
shared memory.
This routing data is very large. It can be fully reloaded through a Kamailio RPC command
(which is done once each day).
When reloading, two sets of data are maintained, one "loading" and another
"current" (the latter being used to handle SIP requests).
When loading of the new data is finished, it is swapped to "current". Then,
memory of the old (now unused) data is freed.
I've noticed that when Kamailio is freeing the old data, there is a very significant
performance impact on SIP requests.
This is surprising to me, because the SIP requests do not use this old data.
This is not a CPU issue, idle CPU% is at about 99% at that moment.
I'm using the following functions :
- shm_mallocxz
- shm_free
From what I understand, shm_free is actually "qm_shm_free" defined in
"src\core\mem\q_malloc.c" (the default shared memory manager being
"qm").
I've noticed that there is also a variant shm_free_unsafe ("qm_free"), which
does not perform locking.
I'm wondering if the lock could be the cause of my performances issues ?
(But I'm not sure how this could be possible, because although the SIP requests need
to access the shared memory allocated, they do not use directly the functions from the
share memory manager.)
If the performances issues are causes by the lock, could I use the unsafe version
"safely" ? (considering that it is guaranteed that the old data cannot be used
by anyone else)
Thanks for your help.
Regards,
Nicolas.
This message contains information that may be privileged or confidential and is the
property of the Capgemini Group. It is intended only for the person to whom it is
addressed. If you are not the intended recipient, you are not authorized to read, print,
retain, copy, disseminate, distribute, or use this message or any part thereof. If you
receive this message in error, please notify the sender immediately and delete all copies
of this message.