lua-users home
lua-l archive

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


On Wed, 3 Dec 2003, Leandro Candido wrote:

> Hello Florian,
> 
>     The answer, in my opinion, is not so if the functions have simple and
> little code, and yes, always gain speed, if functions with big/normal code.
> I'm researching on this subject, I'm trying to create a "lua2c" translator,
> to translate lua code either to lua C API calls (lua_pushnumber, etc...) and
> to mimics the behavior of lvm, but the code isn't useful yet, as I said, I'm
> researching yet, learning the opcodes, etc...
> 
>     Of course, native code always beat interpreted code/bytecode.
> 
>                                                                 God bless
> you,
> 
> 
> Leandro.
>


I have been trying out lua specifically because i am using a platform 
where I believe that the lua byte-codes would execute much, much faster 
than the equivalent native C code.

The processor is a DSP - specifically the Texas Instruments TMS320C6701

It has on-chip, quad ported 256 bit wide memory for VLIW execution of 
program opcodes, very fast.  It also has on-chip memory for data storage 
which is mostly being used for digital audio channels.  We also have 32 
megabytes of SDRAM hooked up to it.

Problem is that the SDRAM runs really slowly as the DSP does not do any 
memory bursting unless it is using DMA.  how slow? 20 to 40 
processor clock cycles to read one 32 bit word from SDRAM.  

In one processor clock cycle, the DSP could load and execute up to 8 
instructions in parallel.  So this means that executing code from SDRAM is 
up to 320 times slower.

As an experiment I took lua-5.0 and hacked it into the dsp's PMEM (Program
Memory).  The idea is that lua's code will run fast from PMEM - a whole 
bunch of code is triggered by a much smaller bytecode in sdram.  I want to 
see if I can write a caching mechanism so that the bytecodes could be 
DMA's into the chip's DMEM temporarily when it is being executed.  I've 
not completed this experment (other things are taking priority), but I 
expect that using lua I can get on average 10 times faster system 
performance compared to native C/C++ code.

jeff