[OpenWrt-Devel] LuaJIT Vs Lua and other questions

Jo-Philipp Wich jo at mein.io
Wed Jun 29 18:16:18 EDT 2016


Hi Anton,

> First I've tried to name package as "luajit" and add CONFLICTS:=lua
> (version should be provided to conflict with) and PROVIDES:=lua
> variables like for RPM to make a replacement package, but I get a
> dependency loop. Therefore, I name produceable packages "lua" and
> "liblua". The problem is that I unable to override default "lua"
> package from openwrt tree (it is not possible to "uninstall", no
> effect of scripts/feeds uninstall ...). Only one possible way is to
> remove "lua" directory from "package" dir and install own luajit pack
> via "scripts/feeds install -p ... luajit". Does mainstream package
> directory has a feed name while it is not separate from build tree
> like an extra openwrt/packages repo and other 3rd party repos? It
> could be fair to have an ability to override core packages with
> "scripts/feeds install".

Overwriting existing packages with other packages having the same name
from external feeds is messy and will always lead to undefined behavior,
don't do that. What would probably work is packaging luajit separately
and replace the existing /usr/bin/lua with a program like:

-- 8< --
#!/bin/sh

if [ -x "/usr/bin/luajit" ]; then
  exec /usr/bin/luajit "$@"
else
  exec /usr/bin/lua.bin "$@"
fi
-- >8 --

> I'm going to use LuaJIT on our BMCs (ARM Aspeed SoC) as a HTTP API
> backend. Nginx compiled with LuaJIT takes about 220 RPS on dynamic
> content (reading one value from i2c bus at each call). With auth
> checking (and caching result of auth via ubus for 1min at Nginx site
> via shared dict) I've got 200 RPS (9% drop). For reference, static
> pages serves by Nginx at 330 RPS. Simple micropython http server
> takes 40 RPS. LUCI + uhttpd is dramatically slow (2-4 RPS) even with
> LuaJIT cause at each request there are a lot and a lot of file
> access.

Did you try uhttpd-mod-lua to avoid bootstrapping with each request? Its
likely still way slower but should offer better performance compared to
execute Lua as CGI.

> Current LuCI modules are not compatible with Nginx (there are
> a lot of global vars read & write). So, as a replacement for IPMI
> proto calls we would prefer to use RPC calls (REST-like) made
> separately from LUCI eco system. We leave LUCI for Web configuration
> staff only.
> 
> Also I found a little complicated to add more authentication methods
> (like AD, LD, Radius, O-Auth and so on). 

You mean PAM? Or authentication for LuCI?

> It's a little tricky, but
> possible. I made O-Auth like http requester to our auth center. For
> HTTP-RPC module it should be done as duplicate code.

You mean the UBUS HTTP RPC?

> Another problem that I've faced is an access from Nginx to ubus
> (nginx runs under "nobody"). I'm able to send requests, but get an
> empty response. Only Nginx running under root lead to receive a
> proper answers. Socket file has enough permissions. What is the
> proper way to configure ubus to allow nginx process to make requests
> to ubus?

You can ship a /usr/share/acl.d/*.json file along with your application
to whitelist certain ubus namespaces/procedures for a given unix user
context, see
https://github.com/openwrt/luci/commit/81e80c4b876e8e68bb8b022c39d0941e2c1ccb56
for example.


HTH,
Jo
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list