Re: Adding assembler code to Lua programs

  • From: Konstantin Olkhovskiy <lupus@xxxxxxxxxx>
  • To: luajit <luajit@xxxxxxxxxxxxx>
  • Date: Fri, 7 Mar 2014 10:55:30 +0400

Concerning the original Luke's question and adding some real life context...

Let's assume that we have some key-value storage engine that holds
MessagePack [1]
encoded objects. Some kind of stored Lua functions are ran upon user
requests and
worst case scenario is searching for an object by a given property with
full table scan.
We may safely assume that all objects have the same structure (or schema).
The number of objects is large, say 50 million, and each object is around
500 bytes.

So that was the context I'm currently in. Just to clarify, I would like to
keep indexes,
sharding, clustering, clouds, etc. out of scope of this thread as it's not
really relevant
to DynASM and LuaJIT.

I had a wild idea of implementing attribute extractor with DynASM that will
craft some
specialized piece of code that skips unnecessary fields and retrieves the
one(s) requested.
Is it sensible to use DynASM for this purpose? Or Lua version can
JIT-compile in something
comparable in performance?

I can think of using DynASM to generate a function, which will be casted to
function pointer
and called via FFI. That's close to the current approach we use, as we use
memmem [2]
function for low-level filtering. But it's imprecise and we have to unpack
and check that the
requested field actually matches.


[1] http://msgpack.org/
[2] http://linux.die.net/man/3/memmem
-- 
Regards,
Konstantin

Other related posts: