lua-users home
lua-l archive

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

On Mon, Sep 25, 2006 at 01:26:24AM +0200, Mike Pall wrote:
> Hi,
> Glenn Maynard wrote:
> > The attached code (creating and destroying copies of references) runs in .42
> > seconds wall time on 5.0.2 for me, and 1.8 seconds on 5.1.
> > 
> > Just pushing the reference (and popping it) is .05 (5.0.2) up to .19 (5.1),
> > which alone is a huge jump.
> > 
> > Same compiler flags.  Before I spend time trying to track this down, does
> > anyone know what's up?   I'm using references as a low-level data type,
> > and I don't want to see a 4:1 overhead increase.
> The 5.1 code for luaL_ref/luaL_unref uses index 0 in the registry
> for the free list. Unfortunately this means it's stored in the
> hash part and not the array part of the registry table. This
> slows down both operations considerably. The equivalent 5.0 code
> uses index 1 for the free list (stored in the array part).
> You could patch lauxlib.c of course (with some care -- changing
> FREELIST_REF alone doesn't work). But for performance sensitive
> use you may be better off rolling your own reference management.
> I suggest to use your own (presized) table, stored in a function
> or userdata environment or an upvalue. And keep track of the
> maximum allocation and the free list anchor on the C side to
> avoid some of the table lookups.

Thanks.  I tried that, and the result is .75 seconds--but that's still
twice the time as 5.0.  Also, the same code running on 5.0 is even
faster than before (.3).

Glenn Maynard