Its not crazy but its lofty and prone to regressions.  It would be similar to database pooling code where it would need to create more if you used up the cached ones etc. 

Lua has its own byte compiled format doesn't it?

Usually when you get past the point that lua is not satisfying, it means you should code it in C.



On Wed, Apr 24, 2013 at 11:58 AM, Vicente Hernando <vhernando@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@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.
>>
>>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting@freeswitch.org
> http://www.freeswitchsolutions.com
>
> FreeSWITCH-powered IP PBX: The CudaTel Communication Server
> http://www.cudatel.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev@lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>


_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-dev mailing list
FreeSWITCH-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org



--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale@hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org
googletalk:conf+888@conference.freeswitch.org
pstn:+19193869900