[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua in high performance apps
- From: "John Belmonte" <jvb@...>
- Date: Tue, 17 Apr 2001 13:07:59 +0900
Joshua Jensen wrote:
> I've used Lua in real-time apps (read: games) with great success, but only
> if I profile and understand where the bottlenecks in the Lua script are.
>
> These are some optimization strategies I use (off the top of my head):
Hi Joshua,
The term "real time" by itself is not very descriptive, and it probably
means something different to each of us. What you are addressing is how to
write Lua scripts that execute quickly, and that is certainly important
know-how. However Lua speed isn't the problem in my case-- I've found it
sufficiently fast for light use (for example calling a few hundred lines of
code per frame). Independent of execution speed is the issue of time spent
collecting garbage, and whether that time is amortized or happens all at
once. Regardless of how lightly I use Lua or how fast my script is, if a gc
cycle comes and causes a missed frame it's "game over".
Unfortunately the weight of the gc cycle is not necessarily related to how
much Lua code I'm executing. For example if I've got a Lua library 10,000
lines in length with plenty of internal state, even if I'm only executing
100 lines of that library code per frame and being careful not to generate
much garbage, eventually that gc cycle will come (given an embedded system
with limited memory) and will have to scan all the objects in the Lua state.
-John