lua-users home
lua-l archive

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


On Wed, Jun 01, 2016 at 04:59:00PM -0300, Roberto Ierusalimschy wrote:
> > Given the performance regressions, is it reasonable to consider some
> > sort of platform #ifdef for the task?
> > 
> > As for the case of memory leakage, is it reasonable to -- on Solaris
> > only if possible -- use full userdata so that the GC can manage
> > things?
> 
> That would make the overhead much higher. (And the ifdef should not be
> "on Solaris only". The problem is not on Solaris nor with LPeg on
> Solaris, but with LuaJIT on Solaris.)
> 

The memory could simply be simply kept in an upvalue. That way allocation
doesn't happen on every invocation. Though, for match() to be re-entrant the
upvalue would need to hold a queue of stacks, only preserve the first stack,
or employ some other strategy.

One benefit of doing this unconditionally is that it might make it easier to
catch bugs which overflow the capture stack, as most tools do a better job
of catching heap overflows than automatic-storage overflows, at least when
the overflow is triggered by non-local, non-inlined code.

Another benefit is that the current code allocates 9KB on the stack; large
stack allocations are unfriendly to code which requires smaller stack
regions.

OTOH, that's alot of trouble for what's currently very simple and concise
code in LPeg.