[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua "amalgamation" for 5-10% speed improvement and ease of use
- From: Aladdin Lampé <genio570@...>
- Date: Wed, 27 Aug 2008 11:48:05 +0200
I was reading the following page related to the SQLite project: http://www.sqlite.org/cvstrac/wiki?p=TheAmalgamation
and found this:
"In addition to making SQLite easier to incorporate into other projects, the amalgamation also makes it run faster. Many compilers are able to do additional optimizations on code when it is contained with in a single translation unit such as it is in the amalgamation. We have measured performance improvements of between 5 and 10% when we use the amalgamation to compile SQLite rather than individual source files."
So I thought it might be a good thing for Lua too to build it as an "amalgamation". I generated "luall.c" with files in the following order (based on modules dependencies): luaconf.h, lua.h, lauxlib.h, lualib.h, llimits.h, lbaselib.c, ldblib.c, lopcodes.h, loadlib.c, ltablib.c, lmathlib.c, lstrlib.c, lauxlib.c, lobject.h, loslib.c, lua.c, liolib.c, linit.c, lmem.h, lopcodes.c, lzio.h, ltm.h, ltable.h, lfunc.h, lgc.h, lapi.h, lstate.h, lparser.h, llex.h, lundump.h, lstring.h, lzio.c, lfunc.c, ldo.h, ldebug.h, ldump.c, lcode.h, lstate.c, lcode.c, print.c, lvm.h, ltm.c, ltable.c, lparser.c, lmem.c, llex.c, lgc.c, lundump.c, lstring.c, ldo.c, ldebug.c, lvm.c, lobject.c, lapi.c
and removed all the "#include" of lua source files inside them.
The generated file compiles almost fine with VS2008 but I had to turn on 2 flags: "LUA_CORE" and "luaall_c" and I get 2 warnings:
- warning C4005: 'LUA_CORE': macro redefinition
- warning C4005: 'VOID': macro redefinition
Note: For some reason, I also had to rename the function "LoadString" to something else because of a conflict with another "LoadStringW" function.
Now, what do you Lua gurus think of all that? Any comments appreciated:
1. Is it after all a good idea to do this amalgamation for Lua?
2. Is it a problem to turn on the 2 flags LUA_CORE and luaall_c?
3. Can I safely ignore the 2 warnings I get about macro redefinition?
4. How can I avoid to rename the "LoadString" function? (because this is unnecessary when compiling each file individually, there shoud be a better way to solve this)
5. Overall, did I do things the right way? or am I missing other obvious ways of doing this?
6. May I get the advertised 5-10% speed improvement with VS2008?
7. If this amalgamation is after all a good idea, is there a chance that it gets supported as a standard way of building Lua in the future?
Thank you for your help,
Plus besoin de clé usb ! Stockez votre musique en ligne gratuitement !