lua-users home
lua-l archive

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


On Friday 13 October 2006 21:48, Gabor Szokoli wrote:
[...]
> > - precompiling. You say configuration files, and talk of LuaJIT.
> > If 
> > you can completely pre-do the compilation phase, you'd definately
> > gain some speed. Question is, if you use the same script multiple
> > times, precompile. If not..
> 
> Yes, the scripts would come from config files, practically never
> reloaded. 
> They in fact constitute configuration of call handling.
> They just get run terribly often :-)

Have you considered implementing a parser/translator/compiler that 
outputs C code, that is compiled into a .dll/.so/... which is then 
loaded and used by the application? Not a great idea if you need fast 
compiles, but it's a relatively easy way of getting very fast 
executables. Also very portable, as you can find good C compilers for 
pretty much anything these days.

Even with a C compiler with a very simple code generator, it won't be 
very hard to beat anything VM based, at least as far as raw "virtual 
instruction" execution speed is concerned. VM instruction decoding is 
*very* expensive in relation to simple instructions such as basic 
arithmetic operations, especially on current generation CPUs with 
deep pipelines, but not all that sophisticated branch handling. 
(switch()es generate close to 100% mispredictions in your average VM. 
There are tricks to deal with this, but even so, the best you can 
hope for is around 50%.)

Of course, in high level languages, the implementation of complex data 
types matters a great deal, and in extreme cases (say, a VM with 
instructions that are wired directly to OpenGL calls), 
per-instruction overhead becomes almost irrelevant. It all depends on 
the application and the language design.


//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'