Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
EMILUA(7)		       Emilua reference			     EMILUA(7)

NAME
       Emilua -	Lua execution engine

DESCRIPTION
       Table 1.	General	concurrency models
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       |		  | Fibers | Threads | Local  |	Distributed | Sandboxed	|
       |		  |	   |	     | actors |	actors	    | actors[1]	|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | cqueues[2]	  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | Tarantool[3]	  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | Effil[4]	  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | Lanes[5]	  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | Lve[6]		  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | ConcurrentLua[7] |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | luaproc[8]	  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+
       |		  |	   |	     |	      |		    |		|
       | Emilua		  |	   |	     |	      |		    |		|
       +------------------+--------+---------+--------+-------------+-----------+

       Do notice that the table	won't go into many details. For	instance,
       several projects	allow you to use threads, but only Emilua is flexible
       enough that it actually allows you to create heterogeneous thread pools
       where some thread may be	pinned to a single Lua VM while	another	thread
       is shared among several Lua VMs,	and some work-stealing thread pool
       takes care of the rest. Too many	tables would be	needed to explore all
       the other differences.

       Integrated IO engine also belongs to the	comparison of concurrency
       models, but a separate table solely focused on them will	be presented
       later (only mentioning the projects that	do have	one).

       Table 2.	NodeJS wannabes
       +---------------+--------+---------+--------------+-----------+
       |	       |	|	  |		 |	     |
       |	       | Fibers	| Threads | Local actors | Sandboxed |
       |	       |	|	  |		 | actors    |
       +---------------+--------+---------+--------------+-----------+
       |	       |	|	  |		 |	     |
       | Luvit[9]      |	|	  |		 |	     |
       +---------------+--------+---------+--------------+-----------+
       |	       |	|	  |		 |	     |
       | LuaNode[10]   |	|	  |		 |	     |
       +---------------+--------+---------+--------------+-----------+
       |	       |	|	  |		 |	     |
       | nodish[11]    |	|	  |		 |	     |
       +---------------+--------+---------+--------------+-----------+
       |	       |	|	  |		 |	     |
       | Emilua	(not a |	|	  |		 |	     |
       | NodeJS	       |	|	  |		 |	     |
       | wannabe)      |	|	  |		 |	     |
       +---------------+--------+---------+--------------+-----------+

       When you	create a project that tries to bring together the best of two
       worlds, you're also actually bringing together the worst	of two worlds.
       This sums up most of the	attempts to mirror NodeJS API:

          If everything is implemented	correctly, it can only achieve being
	   as bad as NodeJS is.

          Horrible back-pressure.

       Table 3.	IO engines
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       |	   | Linux (epoll) | Linux	| BSD (kqueue) | Windows  |
       |	   |		   | (io_uring)	|	       |	  |
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       | cqueues   |		   |		|	       |	  |
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       | Tarantool |		   |		|	       |	  |
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       | Luvit	   |		   |		|	       |	  |
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       | LuaNode   |		   |		|	       |	  |
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       | nodish	   |		   |		|	       | ugly[12] |
       +-----------+---------------+------------+--------------+----------+
       |	   |		   |		|	       |	  |
       | Emilua	   |		   |		|	       |	  |
       +-----------+---------------+------------+--------------+----------+

       This document deliberately left some projects out of the	comparison
       tables. The underlying reason is	that it	focuses	on one problem space:
       the traditional userspace-in-a-modern-OS-box. Projects such as
       eLua[13], NodeMCU[14], XDPLua[15], and Snabb[16]	will always have a
       space in	the market. And	the reason is quite simple: it's not possible
       to cater	for very specific needs	and be general at the same time. For
       instance, if you're trying to run something on the kernel side, there
       are specific restrictions and concerns that will	further	contaminate
       every dependant project down the	line. It's not merely a	question of
       porting the same	API over. The mindset behind the whole program would
       need to change as well.

       Emilua is young and there are plans to explore part of use cases	that
       stretch just a little over the traditional
       userspace-in-a-modern-OS-box. However it	still is a general
       cross-platform solution for an execution	engine.	It's still not
       possible	to tackle very specific	use cases and be general at the	same
       time.

 HTTPS://OPENRESTY.ORG/" OPENRESTY"
       Most of the languages are not designed to make the programmer worry
       about memory allocation failing.	Lua is no different. If	you want to
       deal with resource exhaustion, C	and C++	are the	only good choices.

       A web server written in lua exposed directly to the web is rarely a
       good idea as it can't properly handle allocation	failures or do proper
       resource	management in a	few other areas.

       OpenResty's core	is a C application (nginx). The	lua application	that
       can be written on top is	hosted by this C runtime that is well aware of
       the connections,	the process resources and its relationships to each
       lua-written handler. The	runtime	then can perform proper	resource
       management. Lua is a mere slave of this runtime,	it doesn't really own
       anything.

       This architecture works quite well while	gives productivity to the web
       application developer. Emilua can't just	compete	with OpenResty.	Go for
       OpenResty if you're doing an app	exposed	to the wide web.

       Emilua can perform better for client apps that you deliver to
       customers. For instance,	you might develop a torrent client with	Emilua
       and it would work better	than OpenResty.	Emilua HTTP interface is also
       designed	more like a gateway interface, so we can, in the future,
       implement this interface	as an OpenResty	lib to easily allow porting
       apps over.

          Emilua can also be used behind a proper server.

          Emilua can be used to quickly prototype the architecture of apps to
	   be written later in C++ using an API	that resembles Boost.Asio a
	   lot (and IOFiber <https://github.com/blinktrade/iofiber> will bring
	   them	even closer).

          In the future, Emilua will be able to make use of native plug-ins
	   so you can offload much of the resource management.

          Emilua apps can do some level of resource (under)management by
	   restricting the number of connections/fibers/...

          Emilua won't	be that	bad given its defaults (active async style, no
	   implicit write buffer to deal with concurrent writes, many
	   abstractions	designed with back-pressure in mind, ...).

          The actor model opens up some possibilities for Emilua's future
	   (e.g. partition your	app resources among multiple VMs and feel free
	   to kill the bad VMs).

NOTES
       [1]    Linux namespaces,	Landlock, or Capsicum

       [2]    https://github.com/wahern/cqueues: Designed to be	unintrusive,
	      composable, and embeddable within	existing applications [sic].

       [3]    https://www.tarantool.io/en/doc/2.1/reference/reference_lua/fiber/

       [4]    https://github.com/effil/effil

       [5]    http://lualanes.github.io/lanes/

       [6]    https://love2d.org/wiki/love.thread: Focused on game
	      development.

       [7]    https://github.com/lefcha/concurrentlua: You could rewrite
	      ConcurrentLua on top of Emilua, but you couldn't rewrite Emilua
	      on top of	ConcurrentLua.

       [8]    http://www.inf.puc-rio.br/~roberto/docs/ry08-05.pdf: It has a
	      primitive	model of what could become a full local	actor system.

       [9]    https://luvit.io/

       [10]   https://github.com/ignacio/LuaNode

       [11]   https://github.com/lipp/nodish

       [12]   http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#WIN32_PLATFORM_LIMITATIONS_AND_WORKA

       [13]   https://eluaproject.net/

       [14]   https://nodemcu.readthedocs.io/

       [15]   https://victornogueirario.github.io/xdplua/

       [16]   https://github.com/snabbco/snabb

Emilua 0.11.2			  2025-03-12			     EMILUA(7)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=emilua-alternatives&sektion=7&manpath=FreeBSD+Ports+14.3.quarterly>

home | help