[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT with vectors
- From: Mike Pall <mikelu-1011@...>
- Date: Thu, 18 Nov 2010 11:40:38 +0100
Petri Häkkinen wrote:
> Just to be sure that we're on the same page; I think vectors should be like
> other atomic data types, e.g. like numbers, rather than being objects. This
> would eliminate the allocation cost altogether.
Well, I disagree. There are other ways to eliminate allocations.
Proper API design (pass a reference to a destination vector)
and/or adding escape analysis to the compiler will solve this in
> Modern games are full of vector manipulation, so this is basically the only
> thing stopping us from creating big commercial quality games with LuaJIT.
Please don't spread FUD. This hasn't stopped anybody else from
creating games with LuaJIT. Most of that vector stuff is running
on the GPU or in a physics engine nowadays. Whatever is left, is
either not time-critical and/or the allocations can be eliminated.
> Basically what we did with lua-vec was to double the size of Value struct so
> that it could hold a 4D float vector. Doubling the size of every value is
> quite nasty yes, but perhaps this could be implemented better in LuaJIT...
> What do you think?
No way. Memory bandwidth is one of the top performance bottlenecks
on modern CPUs. You don't want a narrow use case to destroy the
performance of the common case.
have now switched to the 8 byte NaN-tagging value model that's
used by LuaJIT. Esp. Mozilla made extensive measurements before
going for such a major change of their code base. Having a compact
value representation pays off big time for dynamic languages.]