Lua bindings

Neopallium Bindings (latest)

These new Lua bindings add optional support for LuaJIT2's new FFI extension. The bindings will still work with Lua VMs that don't have the FFI extension by falling back to using the standard Lua C API.

Now you can get throughput very close to that of C++ code when running Lua code running under LuaJIT2.

Additional features:

  • zmq.poller which wraps zmq_poll().
  • zmq.threads which make it easy to create threads from Lua that shared a common 0MQ context.

Source Code

https://github.com/Neopallium/lua-zmq

Download build for Windows

Try the LuaJIT 2.0 + zeromq 2.2.0 on Windows 32bit or 64bit:
https://github.com/downloads/Neopallium/lua-zmq/luajit2_zmq2.2_llthreads.zip

Build and installation

ØMQ iteself has to be installed on the system prior to building the Lua binding:

Using LuaRocks 2.0.4.1:

$ sudo luarocks install https://raw.github.com/Neopallium/lua-zmq/master/rockspecs/lua-zmq-scm-1.rockspec

For threads support:

$ sudo luarocks install https://raw.github.com/Neopallium/lua-llthreads/master/rockspecs/lua-llthreads-scm-0.rockspec
$ sudo luarocks install https://raw.github.com/Neopallium/lua-zmq/master/rockspecs/lua-zmq-threads-scm-0.rockspec

With CMake:

$ git clone git://github.com/Neopallium/lua-zmq.git
$ cd lua-zmq ; mkdir build ; cd build
$ cmake ..
$ make
$ sudo make install

Performance

Throughput benchmark using the tcp transport over localhost:
message size: 30 [B]
message count: 100000000

Using send/recv functions running under Lua 5.1.4:
mean throughput: 1577407 [msg/s]
mean throughput: 378.578 [Mb/s]

Using send/recv functions running under LuaJIT2 (git HEAD):
mean throughput: 5112158 [msg/s]
mean throughput: 1226.918 [Mb/s]

Using send_msg/recv_msg functions running under LuaJIT2 (git HEAD):
mean throughput: 6160911 [msg/s]
mean throughput: 1478.619 [Mb/s]

C++ code:
mean throughput: 6241452 [msg/s]
mean throughput: 1497.948 [Mb/s]

Documentation

https://github.com/Neopallium/lua-zmq/blob/master/API.md

Bug Reporting

If you encounter problems please fill a bug report at:

https://github.com/Neopallium/lua-zmq/issues

or write an e-mail to:

moc.mlaerderahs|ybbob#moc.mlaerderahs|ybbob

iamaleksey Bindings (older)

Source Code

http://github.com/iamaleksey/lua-zmq

Build and installation

Following command will build and install the binding into appropriate directory. ØMQ itself has to be installed on the system prior to building the Lua binding:

$ make install

Documentation

http://github.com/iamaleksey/lua-zmq/blob/master/API.md

Bug Reporting

If you encounter problems please fill a bug report at:

http://github.com/iamaleksey/lua-zmq/issues

or write an e-mail to:

moc.oknehcsey|yeskela#moc.oknehcsey|yeskela

FAQ

lua crashes when I use 0MQ?

As lua is designed without multi-thread function, the 'lua' binary is linked without -pthread.
Note this is also needed on Linux (See glibc bug report).

  • Download lua source and rebuild it with -pthread
  • Modify lua-5.1.4/src/Makefile: LIBS= -lm $(MYLIBS) -pthread

More details: http://kasicass.blog.163.com/blog/static/39561920108475639702/

Another option is to preload libpthread.so when running Lua:

  • LD_PRELOAD=/lib/libpthread.so lua

This could be added to a wrapper bash script.

Mailing List

Discussions about the LUA language bindings take place on the general zeromq-dev list.