[Freeswitch-dev] mod_lua speed up

Michael Jerris mike at jerris.com
Wed Apr 24 21:27:53 MSD 2013


if it offers a 1ms improvement per call, then its crazy.  If it offers a 10second improvement per call, its not.

On Apr 24, 2013, at 12:58 PM, Vicente Hernando <vhernando at systemonenoc.com> wrote:

> Hi Michael,
> 
> the goal for us is to compile only once the lua script ( in our case it 
> performs connections to several redis instances ).
> 
> I have still not tested it yet, only wanted to know if it was a crazy 
> idea, or was it just plain impossible.
> 
> When I get the profiling done I will post it here.
> 
> 
> Kind regards,
> Vicente.
> 
> On 04/24/2013 06:21 PM, Michael Jerris wrote:
>> If you profile this, how long do those actually take?  how does that compare to whats needed to clear out a lua state fresh so there is no bleed over to the next usage?
>> 
>> On Apr 24, 2013, at 6:52 AM, Vicente Hernando <vhernando at systemonenoc.com> wrote:
>> 
>>> Hello,
>>> 
>>> looking at src/mod/languages/mod_lua/mod_lua.cpp
>>> 
>>> I see executing lua_init lua_uninit at the beginning and end of every
>>> function, then a lua script is loaded from a buffer, compiled and executed.
>>> 
>>> 
>>> Another approach could be loading some lua scripts at the beginning and
>>> compile them. Then create a pool of lua states.
>>> 
>>> Now everytime lua_init is called, instead of initializing lua again, it
>>> would take a lua state from the pool if available, otherwise it would
>>> create a new one.
>>> 
>>> lua_uninit would reintegrate a lua state into the pool again.
>>> 
>>> 
>>> At the end, when module is finished being used, the whole pool should be
>>> freed.
>>> 
>>> 
>>> Do you thing it is a worthwhile idea or a crazy idea? Any points?
>>> 
>>> 
>>> Thanks in advance,
>>> Vicente.
>>> 
>>> 




Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list