[SR-Users] event_route[core:msg-received] native vs kemi/lua

GG GG ggcoding at gmail.com
Thu Nov 14 05:15:37 CET 2019


The only changes I made in kamailio-basic-kemi.cfg:
debug=-4
children=1
received_route_mode=yes
kemi.received_route_callback="ksr_core_received"

No doubt that kamailio is super fast for SIP routing with native or
kemi/lua.
I was just curious about the impact on cpu with kemi/lua enabled. And the
easiest way was to flood kamailio with random udp packet.



On Wed, Nov 13, 2019 at 3:00 PM Daniel-Constantin Mierla <miconda at gmail.com>
wrote:

> The misc/examples/kemi/kamailio-basic-kemi.cfg can not be with the default
> content, because it doesn't execute ksr_core_received() callback, also it
> has children=2, you said you have 1.
>
> I tested with sipp and the sample kemi lua scripting.
>
> Looking at your iperf command, this is just sending random binary data to
> port 5060 filling 1Gb/sec, but not clear how many udp packets (the size of
> each udp packet). The ksr_core_received() is executed before any attempt to
> parse, so it can be executed also for random binary data, but it is not
> relevant for sip routing point of view what you are testing. Maybe locating
> event_route[core:msg-received] is little bit faster than looking up
> ksr_core_received(), but if we talk here about 1 microsecond vs
> 1.2microseconds, then is irrelevant for overall execution time of routing
> rules for SIP messages.
>
> Cheers,
> Daniel
> On 12.11.19 22:58, GG GG wrote:
>
> I use the /misc/examples/kemi/kamailio-basic-kemi.cfg with log disabled.
> No log is printed at all, on a Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz.
> What's your results ?
>
> # and my lua file
> -- Kamailio - equivalent of routing blocks in Lua
> --
> -- KSR - the new dynamic object exporting Kamailio functions (kemi)
> -- sr - the old static object exporting Kamailio functions
> --
>
> -- Relevant remarks:
> --  * do not execute Lua 'exit' - that will kill Lua interpreter which is
> --  embedded in Kamailio, resulting in killing Kamailio
> --  * use KSR.x.exit() to trigger the stop of executing the script
> --  * KSR.drop() is only marking the SIP message for drop, but doesn't stop
> --  the execution of the script. Use KSR.x.exit() after it or KSR.x.drop()
> --
>
>
> -- global variables corresponding to defined values (e.g., flags) in
> kamailio.cfg
> --FLT_ACC=1
>
> -- SIP request routing
> -- equivalent of request_route{}
> function ksr_request_route()
>         KSR.info("===== request route\n");
> end
>
> function ksr_core_received()
>         KSR.x.exit();
> end
>
> On Tue, Nov 12, 2019 at 4:21 PM Daniel-Constantin Mierla <
> miconda at gmail.com> wrote:
>
>> Do you run with high debug value (lot of log messages)? Because I don't
>> get similar results to yours. Maybe you can share full kamailio.cfg and lua
>> script for both cases.
>>
>> Cheers,
>> Daniel
>> On 12.11.19 22:11, GG GG wrote:
>>
>> Hello,
>>
>> I removed KSR.x.exit() and I got same results for cpu usage and Recv-Q.
>>
>> On Tue, Nov 12, 2019 at 3:56 PM Daniel-Constantin Mierla <
>> miconda at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> can you remove the KSR.x.exit() and test again? It will be the same
>>> effect from sip routing point of view, just to see what is the result.
>>>
>>> Because Lua 'exit' cannot be used, KSR.x.exit() is a workaround relying
>>> on error/exception handling with string comparison that I did.
>>>
>>> However, overall KSR.x.exit() alone has an insignificant effect on a
>>> production configuration, based on the tests I did for kamailio 5.2, you
>>> can look for more at:
>>>
>>>   - https://www.kamailio.org/wiki/kemi/performance-tests/5.2.x
>>>
>>> Cheers,
>>> Daniel
>>> On 12.11.19 21:28, GG GG wrote:
>>>
>>> Hi Daniel,
>>>
>>> For lua example, it's just an error when writing my email... in my
>>> config file I have KSR.x.exit();
>>> I have not tested a more complex config, but I'm curious about kemi
>>> framework and how it works. So before anything else I made a simple test to
>>> know the cpu overhead.
>>> For this test, I noticed that the Recv-Q of kamailio remains high with
>>> kemi/lua, and with the native one remains to 0, with children=1 of course.
>>> Next step, is to use a more complex config file.
>>>
>>> On Tue, Nov 12, 2019 at 3:00 PM Daniel-Constantin Mierla <
>>> miconda at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> is it really just 'exit' in the ksr_core_received()? Because that
>>>> should shut down kamailio.
>>>>
>>>> Anyhow, practically with the examples here, you test the difference
>>>> between looking up a function and doing exit in native kamailio.cfg and lua
>>>> script, which is really marginal comparing with the rest of configuration
>>>> file in a usual production deployment. Have you tested with a more complex
>>>> set of actions/functions?
>>>>
>>>> Cheers,
>>>> Daniel
>>>> On 12.11.19 17:36, GG GG wrote:
>>>>
>>>> Hi!
>>>>
>>>> I just made a simple test performance between native script and
>>>> kemi/lua with the event_route[core:msg-received] callback.
>>>>
>>>> # lua script children=1 cpu.process=100%
>>>> function ksr_core_received()
>>>>   exit;
>>>> end
>>>>
>>>> # native script children=1 cpu.process=70%
>>>> event_route[core:msg-received] {
>>>>   exit;
>>>> }
>>>>
>>>> # tested with udp 5060, 1000 Mbits/sec
>>>> iperf -c 127.0.0.1 -p 5060 -u -b1000m
>>>>
>>>> I don't know if it's normal and what we should expect from kemi, but I
>>>> would like to share this with you. Maybe someone could confirm the
>>>> performance difference.
>>>>
>>>> Have a good day !
>>>>
>>>> _______________________________________________
>>>> Kamailio (SER) - Users Mailing Listsr-users at lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>>
>>>> --
>>>> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
>>>> Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com
>>>>
>>>> --
>>> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
>>> Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com
>>>
>>> --
>> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
>> Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com
>>
>> --
> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
> Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20191113/538ab394/attachment.html>


More information about the sr-users mailing list