[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: void* in Lua_State for Application?
- From: Tim Hill <drtimhill@...>
- Date: Fri, 6 Sep 2013 10:57:26 -0700
On Sep 6, 2013, at 8:55 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> Yes I did. The C API is a mix of heavy-ish functions that do a chunk of work, and some very light operation that just get/set values from a structure; it's these light ones that concerned me.
>>
>> On an x86 system compiled for 64-bit code (cannot recall the CPU, but was recent pedigree), we saw about a 20-30% performance drop when using the registry compared to using a pointer "hidden" in a custom memory allocator for the light APIs. [...]
>
> Thanks for the info. How did you use the registry? Integer keys/lua_rawgeti?
> String keys? (This message is for Miles Bader, too.)
>
> -- Roberto
>
We used lua_rawgeti() on the assumption this was probably the fastest path possible into the registry. I confess we didn't validate that assumption. I think we also tried lua_rawgetp() (using the Lua_State* as the light userdata), but I'm pretty sure it was slower, though I don't have the numbers here.
Understand that this was a *very* tight C function, even in our limited testing it was clear that the Registry overhead wasn't going to be a big deal for normal C functions that did something useful. Sadly, we were stuck with lots of tiny getter/setter APIs as we had to be compatible with an existing API.
As I said, I'm ok with our work-around using a custom allocator and "borrowing" the void* pointer, but it feels "wrong" to use it this way :)
--Tim