Summary:ASTERISK-26806: pjsip_options: rework to make more efficient
Reporter:Kevin Harwell (kharwell)Labels:patch pjsip
Date Opened:2017-02-21 10:46:06.000-0600Date Closed:2018-05-14 04:07:22
Versions:13.14.0 Frequency of
is duplicated byASTERISK-27334 Pjsip Performance issues with qualify enabled
is related toASTERISK-26599 res_pjsip: High startup time using local configuration files
is related toASTERISK-26730 13.13.1 with bundled pjproject with optimization used cpu twice more then 13.7.2
Environment:Attachments:( 0) ASTERISK-26806.diff
( 1) endpoint_ids.1000
( 2) endpoint_ids.2000
( 3) endpoint_ids.3000
( 4) pjsip.conf.1000.txt
( 5) pjsip.conf.2000.txt
( 6) pjsip.conf.3000.txt
( 7) pjsip.conf.txt
( 8) register-noauth-inject.xml
( 9) subscribe-inject.xml
Description:Currently the pjsip_options code is plagued with efficiency issues. Testing revealed a marked increase in CPU utilization between versions (at least between 13.7.0 and the current branch/13.14+).

Testing included ~3000 loaded (via config file) endpoints where at least 500 of those were then registered and subscribed. On my machine I noticed at least a 10-15% cpu increase between versions when options were being sent out. Turning off options (qualify_frequency=0) I noted no increase in cpu.

Two primary issues need to be resolved:

1.  Find out why we are spending more time now when sending notifies and fix it.

2. If static contacts are used or a bunch of endpoints have registered and asterisk is [re]started/[re]loaded there is a significant slowdown within the options code. This actually blocks until it completes, which as the number of registered contacts increases so does the block/wait time. This needs to be fixed as well.
Comments:By: Kevin Harwell (kharwell) 2017-02-21 11:01:13.117-0600

Attached conf files for 3000 endpoints. Also attached sipp scenarios that can be used to register and subscribe the endpoints. For instance to register 500 endpoints something like the following can be executed:
sipp -p 5061 -m 500 -sf register-noauth-inject.xml -inf endpoint_ids.1000

By: Daniel Journo (journo) 2017-03-25 17:59:31.950-0500

With 300+ endpoints registered and qualified, I've also noticed that when I issue 'pjsip reload' via the CLI, the CLI output freezes until the command completes.

In addition, occasionally during peak usage, 'pjsip reload' issued via AMI causes endpoints to lose registration and calls to drop. I dont know if that is related and don't know if the same occurs when the command is issued via the CLI.

Finally, 'pjsip show endpoints' causes the CLI to freeze until the command completes.

By: Daniel Journo (journo) 2017-06-27 07:44:42.665-0500

Just to update this, occasionally, 'pjsip reload' causes chan_pjsip to stop responding to packets. In my environment, there are around 300 endpoints. I'm using static files.

By: Joshua C. Colp (jcolp) 2017-12-20 13:24:15.012-0600

I've attached my rewrite of OPTIONS support which should resolve the performance issues and still be good. This is against 13.

It needs to go to through more testing but if anyone wants to try it, then they can.

By: Friendly Automation (friendly-automation) 2018-05-14 04:07:25.795-0500

Change 7710 merged by Joshua Colp:
pjsip: Rewrite OPTIONS support with new eyes.


By: Friendly Automation (friendly-automation) 2018-05-14 04:07:39.298-0500

Change 8752 merged by Joshua Colp:
pjsip: Rewrite OPTIONS support with new eyes.


By: Friendly Automation (friendly-automation) 2018-05-14 04:07:50.698-0500

Change 8758 merged by Joshua Colp:
pjsip: Rewrite OPTIONS support with new eyes.