[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: void* in Lua_State for Application?
- From: Tim Hill <drtimhill@...>
- Date: Thu, 5 Sep 2013 13:05:40 -0700
On Sep 5, 2013, at 11:43 AM, Tom N Harris <firstname.lastname@example.org> wrote:
> On Wednesday, September 04, 2013 08:42:48 PM Coda Highland wrote:
>> 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.
> So it's just the classic speed-vs-space tradeoff. Either waste time doing a
> table lookup for the people who need it, or waste a pointer-sized field in
> lua_State for the people who don't need it.
> LUAI_EXTRASPACE is kind of a nice compromise since the it costs nothing if you
> don't use it. At the cost of having to recompile. But that may be necessary
> anyway in uses where the registry isn't an option. For example, to store a
> per-state mutex.
> tom <email@example.com>
Hmmm … i'd say the cost of ONE void* pointer in a Lua_State was pretty insubstantial, even if you spin up a LOT of them. it may even be free, since most heap managers round up allocated sizes to some power of 2 multiple, so the actual size of the allocated Lua_State may not change.