lua-users home
lua-l archive

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


Hi List,
 
I am working on a project to build sytem using reactive programming paradigm,
 
http://en.wikipedia.org/wiki/Reactive_programming
 
This system heavily depends on meta programming at run time, so requires many cycle of source code ==> abstract syntax tree ==> source code ==> loadstring transfer. The efficiency of each step is very critical. After some research, I used metalua to do this. However I find the performance of metalua is not that great.
 
By using a top nitch personal computer (I don't remember the exact spec), I did a simple performance test to use metalua, Lua loadstring to parse a typical 600 lines source file with certain requires statement, and at the same time compare it with python in parsing a similar length python source file with several import. The performance like the following
 
1000 cycles
 
metalua src to ast:                   82 sec
metalua ast to src:                   93 sec
lua loadstring:                          0.8 sec
python standard ast library:       8,5 sec
 
so lua loadstring is x10 faster than python
and lua loadstring is x100 faster than metalua lua
 
I understand this is far from a scientific performance test, as comparing python with Lua is hard to be fair, and Lua loadstring doesn't need to transfer into ast internally. However I still expect metalua's performance could match that of python, as Lua is instrically a simpler language than python.With such speed, my project would for sure suffer from performance issue if I were to use metalua.
 
My quesiton to the list is that, is there any way to boost metalua performance, or is there any other library could offer better performance? One thing l like metalua is that AST has line info which make it easy to write my debugger, so I would like the new library also provide line info when parsing AST.
 
Also I am very impressed by Lua loadstring performance, so wondering if it is easy to transfer Lua compiler into AST with line info? If it is possible, i would naviely imagine this would greate an AST library that is as fast as loadstring.