[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Next Version of Lua?
- From: Niklas Frykholm <niklas@...>
- Date: Fri, 12 Jun 2009 12:30:02 +0200
2009/6/11 steve donovan <steve.j.donovan@gmail.com>:
> Thinking about 3D vectors as objects, I'm sure a C++ application would
> struggle with lots of tiny objects like that, and it would certainly
> cause a lot of allocation churn unless some clever reusing was going
> on. Surely the userdata needed here is an _array_ of 3D vectors, to
> efficiently handle the storage and processing of many vectors?
Yes, if the 3D vectors were allocated on the heap using
run-of-the-mill malloc, then C++ would have problems too. (The memory
access patterns are often the bottleneck.) But in a normal C++
application the 3D vectors would be value types and live on the stack
rather than the heap and thus would be very quick to create and
destroy. But lua userdata must live on the heap, so in Lua we are
forced into the slow behavior.
Yes, for SIMD applications you could have a userdata representing an
"array of Vector3" and get very fast vectorized operations using a
library similar to NumPy. But in my case the issue is lots of small
computations that cannot be easily vectorized.
// Niklas
- References:
- Next Version of Lua?, Olivier Hamel
- Re: Next Version of Lua?, Jim Whitehead II
- Re: Next Version of Lua?, Olivier Hamel
- Re: Next Version of Lua?, Niklas Frykholm
- Re: Next Version of Lua?, Duncan Cross
- Re: Next Version of Lua?, Niklas Frykholm
- Re: Next Version of Lua?, Asko Kauppi
- Re: Next Version of Lua?, Niklas Frykholm
- Re: Next Version of Lua?, Asko Kauppi
- Re: Next Version of Lua?, steve donovan