lua-users home
lua-l archive

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


Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:
>> Performance, mostly. That's a table lookup worth of overhead for every
>> function that needs to fetch it. A C function accessing a field in the
>> lua_State is substantially faster.
>
> Did you benchmark it for any real case (that is, a case that will waste
> some time doing something useful with the retrieved pointer)?

I'm not the original poster, but I've benchmarked cases where using an
upvalue to store <some value needed by my C function> doubled the
speed of my code compared to the same code except using the registry
(despite all the other overhead present in calling into C from Lua)...

[I dunno exactly how upvalues are implemented, but they certainly seem
to be faster than the registry, and I imagine a simple
pointer-in-lua_State would be faster still..]

-miles

-- 
Somebody has to do something, and it's just incredibly pathetic that it
has to be us.  -- Jerry Garcia