You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Daniel Gruno <ru...@cord.dk> on 2013/04/25 16:24:02 UTC

Default value of LuaScope in trunk mod_lua

Hi dev@ people,

I'm thinking of changing the default value of LuaScope in trunk to
'thread', as the current default, 'once', has a significant performance
impact (as I explained at ApacheCon). As Lua's garbage collector is
quite awesome (it's virtually impossible to leak memory unless you
deliberately do so), I don't see a reason why we should stick with
'once' on threaded platforms, especially considering the overhead of
reloading libraries into the VMs if they are created and thrown away
after each request. I would also like for this to get backported to 2.4
at some point, which is why I'm throwing you this email as a heads up.

Thoughts? ideas? heckling?

With regards,
Daniel.

Re: Default value of LuaScope in trunk mod_lua

Posted by Brian McCallister <br...@skife.org>.
+1 as long as we make it very obvious that is what it is. A risk is that
when a developer is hacking, refreshing, hacking, refreshing they *will*
always get the same VM, so they will expect that behavior and be surprised
when it is used concurrently.


On Thu, Apr 25, 2013 at 9:13 AM, Eric Covener <co...@gmail.com> wrote:

> I say go for it, it's an experimental module in 2.4.
>

Re: Default value of LuaScope in trunk mod_lua

Posted by Eric Covener <co...@gmail.com>.
I say go for it, it's an experimental module in 2.4.

Re: Default value of LuaScope in trunk mod_lua

Posted by Daniel Gruno <ru...@cord.dk>.
On 04/25/2013 04:41 PM, Eric Covener wrote:
> On Thu, Apr 25, 2013 at 10:24 AM, Daniel Gruno <ru...@cord.dk> wrote:
>> Hi dev@ people,
>>
>> I'm thinking of changing the default value of LuaScope in trunk to
>> 'thread', as the current default, 'once', has a significant performance
>> impact (as I explained at ApacheCon). As Lua's garbage collector is
>> quite awesome (it's virtually impossible to leak memory unless you
>> deliberately do so), I don't see a reason why we should stick with
>> 'once' on threaded platforms, especially considering the overhead of
>> reloading libraries into the VMs if they are created and thrown away
>> after each request. I would also like for this to get backported to 2.4
>> at some point, which is why I'm throwing you this email as a heads up.
>>
>> Thoughts? ideas? heckling?
> 
> You mentioned before some corner case with scripts relying on
> globals/statics/??? that this would affect. Can you give an idea of
> how corner that is?
> 
There could be some issues where a (bad bad bad) programmer relies on
variables being undefined or set to a default when the script enters a
function, but any respectful Lua programmer knows you *always use local
variables*. The 'problem' arises when two scripts share the same VM, and
the owner of script A assumes that he is in full control of global
variables, but script B does something stupid and changes, fx. os.time
to nil. In this case, you'd need to reload the os library with "require
'os'".

However, on the plus side, you have
1) Faster loading of all pages, since the VM doesn't need to be created
2) Less malloc/free since your libraries are only loaded once
3) you can set persistent values that you only need to generate once per
thread, fx something that requires a lot of cpu cycles.
4) You only need to load and compile scripts from disk once (unless they
changed since last compilation)

So yes, there are caveats, but I personally consider it insignificant
compared to the big performance boost it gives you, and I don't consider
the caveats big enough to warrant 'once' as the default scope. But as I
said, comments/thoughts are most welcome, and I will take them under
advisement :)

With regards,
Daniel.

Re: Default value of LuaScope in trunk mod_lua

Posted by Eric Covener <co...@gmail.com>.
On Thu, Apr 25, 2013 at 10:24 AM, Daniel Gruno <ru...@cord.dk> wrote:
> Hi dev@ people,
>
> I'm thinking of changing the default value of LuaScope in trunk to
> 'thread', as the current default, 'once', has a significant performance
> impact (as I explained at ApacheCon). As Lua's garbage collector is
> quite awesome (it's virtually impossible to leak memory unless you
> deliberately do so), I don't see a reason why we should stick with
> 'once' on threaded platforms, especially considering the overhead of
> reloading libraries into the VMs if they are created and thrown away
> after each request. I would also like for this to get backported to 2.4
> at some point, which is why I'm throwing you this email as a heads up.
>
> Thoughts? ideas? heckling?

You mentioned before some corner case with scripts relying on
globals/statics/??? that this would affect. Can you give an idea of
how corner that is?