lua-users home
lua-l archive

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

> I'm not sure that its a problem at all. You should worry more 
> about garbage
> collection.

This might be handled easily by asking for a large GC cycle length,
then manually calling the GC at appropriate times. I do it whenever
a new map loads, so there is a stall already. Depending on your case,
however, if loads are very sparse, it might not be a solution.

> Not sure you'd need to. Classically, if your script isnt working 
> fast enough
> you profile it and move more of the code into C/C++. Using any embedded
> script efficiently is about drawing the interface line correctly.

I was wondering whether I should, once the scripts are stable, convert
all or most of it to C++ code and link it. The problem is basically size.
It's easy to get rid of Lua code whenever it's not needed any more, and
it's not that easy for linked code, though virtual memory could help
here. So, though all internals are in C++, I'll keep all my AI and object
logic in Lua, which is convenient. So convenient, in fact, that the whole
behavior of my objects is (or will be) defined in Lua. The speed of the
language then becomes an issue.
As an example, the tables I associate with a C++ object all have a field
in common, a userdata which points back to the C++ object to which they
refer. Though table lookup is done in constant time, I modified the
table structure to hold this pointer (I only use it from the C++ side).
This is an extreme example, but I can think of other things I'd like to
be fast: function calls (mainly betweem Lua and its host) are the first
one. I have not yet tried to convert my code to the new (4.0 beta) API,
but I'm waiting for it with happiness :)
So I guess a sensible answer would be to, once most of the scripts are
prototyped, to try to factor out what you can of those, and move them
to C/C++ code, as Nick suggested. The little optimizations like changing
the table structure are worthwhile for me, because I use it at every
engine API call from Lua, and was a easy and quick hack. The rest would
probably not be. Taking days or weeks to improve it ? The graphics engine
surely would benefit more from speedups ;)

Vincent Penquerc'h