[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Private data
- From: "Joshua Jensen" <jjensen@...>
- Date: Wed, 3 Oct 2001 23:21:55 -0600
> >accessing a table is still needlessly slow.
> Any table? Or just the registry?
> Do you have hard data on how much it slows your application?
> We'd be interested in that. Thanks. --lhf
I'd like to interject here for a moment. Obviously, Lua is a general
purpose language that some of us (me) try to customize greatly toward a
very specific task (such as the memory optimizations I did, which I'm
still going to post as soon as I get two seconds to do so). I can't
speak for Curt, but I am most interested in Lua's performance (both
speed and memory) in games. I understand that by dealing with a
typeless language, I am setting myself up for slower performance than a
typed language. I won't give up the flexibility of Lua for the faster
performance of a typed language, but I am going to make it as quick as I
can for my applications.
That said, ANY type of table lookup is much slower than a straight array
access. I don't believe Curt is asking for indexed arrays in Lua
itself, but by providing himself an array, he has very quick constant
time lookup for whatever functionality he needs it for.
I noticed this in Amped in the transition between Lua 4.0 and 4.1 Alpha.
Amped used to use a LOT of lua_ref() and lua_getref() calls. I noticed
a frame rate slowdown between the two versions and the culprit was the
new hashed lookup for ref'ed items. The simplest solution for me was to
rework my C code to not use the lua_ref() approach. This is a place
where the more "array-oriented" approach of Lua 4.0 was preferred (from
a gaming standpoint).
(The second part of this was the increase in memory usage due to the use
of the table. I don't have a copy of Lua 4.0 handy, but it seems to me
that Lua 4.0 didn't store the key TObject.. Only the value TObject.
Given the size of a TObject and the amount of refs I had, it was
impractical to access my data in this form anymore).
For this reason, I wish that indexed arrays were built into the Lua VM
as a specialized type. This is, again, for gaming purposes, but the
memory saved for embedded platforms could be great, also.