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

 

From: Chaigneau, Nicolas <nicolas.chaigneau@capgemini.com>
Sent: Wednesday, January 18, 2023 6:49 PM
To: Kamailio (SER) - Users Mailing List <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.