[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: On lua5 and embedding
- From: "Bilyk, Alex" <ABilyk@...>
- Date: Tue, 28 Jan 2003 16:37:19 -0800
Yes, the caching is done. But... To my taste it is done for the wrong case. Namely, culling non-existent meta-methods for some selected events is the fastest case (just a flag check). But access to any existing meta-method is a Lua-table lookup. I am not saying the caching is not possible, it is very much possible, I am just saying it has not been done for either shortage of time or a disregard to this particular aspect of implementation altogether. This is all theory however. In practice, this needs to be carefully benchmarked with some real world applications in mind and the decision has to be made whether or not it makes sense to do this. We are using Lua in games. Every bit of speed improvement is a benefit. If someone writes CGI scripts, networking apps or file utilities why would they care? In such cases they wouldn't notice another 10x slowdown on meta-tables. 1GHZ CPU does IO so much faster than any network or disk IO that it is utterly pointless to even bother thinking about this kind of stuff, IMHO:) In games you usually have so much other things fighting for CPU clocks withing the same application that every milisecond saved on script execution is a very desirable thing to have.
AB
-----Original Message-----
From: jimmyp_gr <jimmyp@hal.csd.auth.gr> [mailto:jimmyp@hal.csd.auth.gr]
Sent: Tuesday, January 28, 2003 3:31 PM
To: Multiple recipients of list
Subject: Re: On lua5 and embedding
--- In lua-l@yahoogroups.com, "Bilyk, Alex" <ABilyk@m...> wrote:
> Yeah, I was complaining about this as well. Then someone said that
__get and __set have been removed as a speed improvement. Curiously
enough, IMHO, one could actually do more with tags in Lua4 and it
would run faster as well. Meta-tables are slower and you'd want to get
rid of anything you can get away with while using them. In fact, in
current implementation of Lua5 Beta, it is partially optimized for
when one does NOT use meta-methods (Duh! What an important case for a
language whose main virtue is meta-table based extensibility).
Strange... To me tag methods and metamethods look a lot alike.Is the
table lookup to get the method what causes the slowdown.
> Basically, as long as one runs plain vanilla Lua5 scripts they will
go pretty fast. But as soon as one starts using inheritance, call and
other meta-methods on their objects that is when the meta-method
overhead jumps in. Syntax-wise meta-tables are pretty but with respect
to functionality they are impaired feature-wise as well as speed-wise,
in may view, compared to tags in Lua4 (boy, am I repeating myself or
what?). My only hopes are that meta-methods access will get optimized
at some point for a case when one actually uses them and that
computers are getting faster and faster allowing applications to
become a little more wasteful in terms of CPU and memory use and
letting programmers become less thoughtful at the same time.
I still don't get this.Can't some sort of caching system be
implemented.For example when settagmethod is called it can get the
values(or function pointers) of the defined metamethods and cache them
in an internal C table.Then the code to return the value of an
object(that is the __getindex or __get calls) could look like:
#define __GET somevalue
method=internal[__GET];
if(method==NULL)
return luavalue(...);
else
method(...);
Now that can't be so much slower than just:
return luavalue(..);
unless maybe inside a loop or something but then again lua is an
interpreted scripting language.