lua-users home
lua-l archive

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

More fun stuff:

d'Arc is a sub API for Lua and LuaJIT. It reaches below the official Lua API for faster access, and often needs less memory. I think it could help bridging the divide opening up between the original and JIT VM. d'Arc can be used to make libraries for both Lua and LuaJIT faster (depends a lot on what the lib does, for some things more than 2 times), and makes it easier to write patches that target both Lua and LuaJIT.

d'Arc allows you to use direct C pointers to variable contents, in a clear and unified way. Write once, works for both Lua and LuaJIT. It's a beaut, tell you. Just as the official API but faster. Actually, it's simpler, too.


char *s = XLUA_STRING(variable);

Plus, you get to traverse tables much faster, in both Lua and LuaJIT. You get a traversal function for that, that takes a callback:

        darc_traverse(XLUA_TABLE(variable), my_callback, my_state);

This is faster than the official API, ~2 - 6 times, because it skips quite numerous function calls and hash calculations behind the scene.

There are benchmarks here:

There is a really interesting anomaly in the last line of the benches: the sample traversal of  |10.000 elements in a table t[i*100]=<random strings> is faster in Lua than LuaJIT. This would point to |the underlying table access code - the core of it, behind the official API - to be implemented faster for sparse arrays in Lua than in LuaJIT! Who'da thunk!

In case you want to follow events back stage:

There's a lot of doc and inspections there: if you find an error, sure glad to hear about it.

Have fun,