[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Sandboxed Lua] Limit execution time, loop iterations and memory usage
- From: HyperHacker <hyperhacker@...>
- Date: Wed, 9 Jun 2010 11:42:44 -0600
On Wed, Jun 9, 2010 at 02:35, <email@example.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" <firstname.lastname@example.org>
> Gesendet: Dienstag, 8 Juni, 2010 16:33
> An: "Lua list" <email@example.com>
> Betreff: Re: [Sandboxed Lua] Limit execution time, loop iterations and memory usage
> On Tue, Jun 8, 2010 at 10:30 AM, Kurt Nordstrom
> <firstname.lastname@example.org> wrote:
>> Also, look at the debugging hooks in the C API.
>> I'd be interested in seeing a good solution to limiting memory
> There is a good solution, give Lua an allocator that has a limit on
> the amount of memory .
>  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.