lua-users home
lua-l archive

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


On 3.4.2010, at 12.04, Alex Davies wrote:

> LuaJIT 2.x is clever enough that it stores all values including type info and even on 64 bit architectures in just 8 bytes.  Again with the number of stack copies Lua does - and the fact that the array component of a table needs to be able to hold every type of value (ie that's 8 bytes per value even for an array of boolean) that's a very nice property to have.
> 
> If it can't be made garbage collected, Value size is doubled =( and it'd be a massive change to Jit 2.x.  It might not be as slow as you think - a dedicated gc type is a lot faster then userdata, which has a lot of extra gc backend to do with finalizers, environment tables etc.  Only other idea that comes to mind is half precision.. but that's pretty limited.


Thanks for the feedback!

Implementing a custom gc type is something we haven't explored yet. However to achieve speed similar to value type vectors, a custom memory allocator needs to be rewritten - dynamic memory allocation for each new temp vector created is a sure performance killer on most platforms.

I agree that 8 extra bytes is not the optimal solution but depending on the context it might not matter that much. It all depends how much persistent data the app is using. For example in a game, the actual content (textures, models, animations sounds, etc.) usually far exceed the memory usage of game state. Sure, bigger memory footprint may affect cache performance negatively thus slowing down execution.

That said, we'll certainly give the custom gc vec idea a shot. I think we'll be much wiser when we get the perf data.

Petri