lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jun 9, 2010 at 02:35,  <moltrecht@topconcepts.com> wrote:
> Thanks you for all your answers, I managed to limit CPU time and memory using the "ulimit" command.
> But now there is a performance issue. I ran some tests on the current testing system and found out that launching the Lua parser (from my PHP script) takes around 0.02 seconds, almost exactly the time it takes to calculate the sine 100.000 times. Since the sandboxed Lua is supposed to be ran a few times for each PHP site parsed, this may cause serious performance problems (0.02s for intepreter + 0.02s for script = 0.04s, 0.04s * 10 = 0.4s, and this is just the Lua part, without any MySQL or PHP).
> Is there any possibility of running the interpreter all the time and just sending it commands which scripts to execute and then stream the output back to my PHP script? This would eliminate the need to start the interpreter again and again.
>
> Your help would really be appreciated,
> Lennart Moltrecht
>
> -----Ursprüngliche Nachricht-----
> Von: "Patrick Donnelly" <batrick@batbytes.com>
> Gesendet: Dienstag, 8 Juni, 2010 16:33
> An: "Lua list" <lua@bazar2.conectiva.com.br>
> Betreff: Re: [Sandboxed Lua] Limit execution time, loop iterations and memory usage
>
> On Tue, Jun 8, 2010 at 10:30 AM, Kurt Nordstrom
> <doseofvitamink@gmail.com> wrote:
>> Also, look at the debugging hooks in the C API.
>> http://www.lua.org/manual/5.1/manual.html#lua_Hook
>>
>> I'd be interested in seeing a good solution to limiting memory
>> over-allocation.
>
> There is a good solution, give Lua an allocator that has a limit on
> the amount of memory [1].
>
> [1] http://www.lua.org/manual/5.1/manual.html#lua_Alloc
>
> --
> - Patrick Donnelly
>
>
>

You could certainly run your script separately from PHP, in a loop,
and let the two communicate via pipes or sockets.

-- 
Sent from my toaster.