You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rainer Jung <ra...@kippdata.de> on 2011/11/11 11:16:50 UTC

Lua state reuse does not work

I did a few lua tests and currently the reuse of lua states does not 
work. Unfortunately I don't yet see the root cause.

We are constantly creating new lua states, saving them to the pool and 
on the next request retrieve null and create a new state. When the 
server is shutdown, all of the states are cleaned up together. This is 
true for conn and thread scope and for prefork, worker and event. I'm 
using apr trunk.

Regards,

Rainer




Re: Lua state reuse does not work

Posted by Eric Covener <co...@gmail.com>.
> 2) Because I had the "LuaScope" directive below the <LuaQuickHandler>
>   container. Needs to move before! Should order matter?

I guess it matters due to exec-on-read of the config sections.  We
could probably retrieve this scope info from the dirconfig when the
corresponding hook actually runs rather than using the one that is
stashed in the "hook_spec".

Re: Lua state reuse does not work

Posted by Rainer Jung <ra...@kippdata.de>.
On 11.11.2011 02:16, Rainer Jung wrote:
> I did a few lua tests and currently the reuse of lua states does not
> work. Unfortunately I don't yet see the root cause.
>
> We are constantly creating new lua states, saving them to the pool and
> on the next request retrieve null and create a new state. When the
> server is shutdown, all of the states are cleaned up together. This is
> true for conn and thread scope and for prefork, worker and event. I'm
> using apr trunk.

More info ahead: the pool we were using was the request pool, even when 
using scope conn or thread.

The note about all cleanups running at shutdown was a red herring due to 
missing flush in added debug output.

Why is it the request pool?

1) Because I used a handler defined inline in the config
    (as a LuaQuickHandler) the code use r->pool fixed. See Patch below.

2) Because I had the "LuaScope" directive below the <LuaQuickHandler>
    container. Needs to move before! Should order matter?

Rough performance result: Serving 2 Bytes via event before the patch lua 
was about 40% of the request throughput than serving a static file. 
After the patch lua content in quick handler is about 3 times as fast as 
static files. Both tests with a pretty small set of loaded modules and 
access log off. When moving lua to a normal handler via AddHandler I 
still get about twice the request throughput with lua compared to static 
files. Next would be to check how big the overhead of calling into lua 
is, e.g. comparing a fast static setup with static plus a few lines of 
lua in a hook.

Regards,

Rainer