<div dir="ltr">The only changes I made in kamailio-basic-kemi.cfg:<div>debug=-4<br></div><div>children=1<br></div><div>received_route_mode=yes<br></div><div>kemi.received_route_callback="ksr_core_received"<br></div><div><br></div><div>No doubt that kamailio is super fast for SIP routing with native or kemi/lua.</div><div>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.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 13, 2019 at 3:00 PM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">
    <p>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.</p>
    <p>I tested with sipp and the sample kemi lua scripting.</p>
    <p>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.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div>On 12.11.19 22:58, GG GG wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>
          <div>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.</div>
          <div>What's your results ?</div>
          <div><br>
          </div>
          <div># and my lua file</div>
          <div>-- Kamailio - equivalent of routing blocks in Lua<br>
            --<br>
            -- KSR - the new dynamic object exporting Kamailio functions
            (kemi)<br>
            -- sr - the old static object exporting Kamailio functions<br>
            --<br>
            <br>
            -- Relevant remarks:<br>
            --  * do not execute Lua 'exit' - that will kill Lua
            interpreter which is<br>
            --  embedded in Kamailio, resulting in killing Kamailio<br>
            --  * use KSR.x.exit() to trigger the stop of executing the
            script<br>
            --  * KSR.drop() is only marking the SIP message for drop,
            but doesn't stop<br>
            --  the execution of the script. Use KSR.x.exit() after it
            or KSR.x.drop()<br>
            --<br>
            <br>
            <br>
            -- global variables corresponding to defined values (e.g.,
            flags) in kamailio.cfg<br>
            --FLT_ACC=1<br>
            <br>
            -- SIP request routing<br>
            -- equivalent of request_route{}<br>
            function ksr_request_route()<br>
                    KSR.info("===== request route\n");<br>
            end<br>
            <br>
            function ksr_core_received()<br>
                    KSR.x.exit();<br>
            end<br>
          </div>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 4:21
          PM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div bgcolor="#FFFFFF">
            <p>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.</p>
            <p>Cheers,<br>
              Daniel<br>
            </p>
            <div>On 12.11.19 22:11, GG GG wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div>Hello,</div>
                <div><br>
                </div>
                <div>I removed KSR.x.exit() and I got same results for
                  cpu usage and Recv-Q.</div>
                <br>
                <div class="gmail_quote">
                  <div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019
                    at 3:56 PM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>>
                    wrote:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                    <div bgcolor="#FFFFFF">
                      <p>Hello,</p>
                      <p>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.</p>
                      <p>Because Lua 'exit' cannot be used, KSR.x.exit()
                        is a workaround relying on error/exception
                        handling with string comparison that I did.</p>
                      <p>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:</p>
                      <p>  - <a href="https://www.kamailio.org/wiki/kemi/performance-tests/5.2.x" target="_blank">https://www.kamailio.org/wiki/kemi/performance-tests/5.2.x</a></p>
                      <p>Cheers,<br>
                        Daniel<br>
                      </p>
                      <div>On 12.11.19 21:28, GG GG wrote:<br>
                      </div>
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div>Hi Daniel,</div>
                          <div><br>
                          </div>
                          <div>For lua example, it's just an error when
                            writing my email... in my config file I
                            have KSR.x.exit();</div>
                          <div>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.</div>
                          <div>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.</div>
                          <div>Next step, is to use a more complex
                            config file.</div>
                          <br>
                          <div class="gmail_quote">
                            <div dir="ltr" class="gmail_attr">On Tue,
                              Nov 12, 2019 at 3:00 PM Daniel-Constantin
                              Mierla <<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>>
                              wrote:<br>
                            </div>
                            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                              <div bgcolor="#FFFFFF">
                                <p>Hello,</p>
                                <p>is it really just 'exit' in the
                                  ksr_core_received()? Because that
                                  should shut down kamailio.</p>
                                <p>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?</p>
                                <p>Cheers,<br>
                                  Daniel<br>
                                </p>
                                <div>On 12.11.19 17:36, GG GG wrote:<br>
                                </div>
                                <blockquote type="cite">
                                  <div dir="ltr">Hi!
                                    <div><br>
                                      <div>I just made a simple test
                                        performance between native
                                        script and kemi/lua with
                                        the event_route[core:msg-received]
                                        callback.</div>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div># lua script children=1
                                      cpu.process=100%</div>
                                    <div>function ksr_core_received()<br>
                                    </div>
                                    <div>  exit;</div>
                                    <div>end</div>
                                    <div><br>
                                    </div>
                                    <div># native script children=1
                                      cpu.process=70%</div>
                                    <div>event_route[core:msg-received]
                                      {</div>
                                    <div>  exit;</div>
                                    <div>}<br>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div># tested with udp 5060, 1000
                                      Mbits/sec</div>
                                    <div>iperf -c 127.0.0.1 -p 5060 -u
                                      -b1000m</div>
                                    <div><br>
                                    </div>
                                    <div>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.</div>
                                    <div><br>
                                    </div>
                                    <div>Have a good day !</div>
                                  </div>
                                  <br>
                                  <fieldset></fieldset>
                                  <pre>_______________________________________________
Kamailio (SER) - Users Mailing List
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
                                </blockquote>
                                <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
                              </div>
                            </blockquote>
                          </div>
                        </div>
                      </blockquote>
                      <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
                    </div>
                  </blockquote>
                </div>
              </div>
            </blockquote>
            <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
  </div>

</blockquote></div>