[OpenWrt-Devel] LuaJIT Vs Lua and other questions
Anton D. Kachalov
mouse at yandex-team.ru
Thu Jun 30 03:26:08 EDT 2016
Hello, Jo.
30.06.2016, 01:15, "Jo-Philipp Wich" <jo at mein.io>:
> 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 --
This variant do not solve packages' dependencies problem. And I still need to somehow recompile (and disable mainstream "lua" first) packages with LuaJIT libs. Brute replacement works better in such case. I don't want to waste space for two Lua version in the system.
Just a generic question – what is the obstacles to move from Lua interpreter to LuaJIT? There are minor changes in regexp's quotes. Other things seems to work. I've completely recompile stuff with LuaJIT.
>> 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.
Yeap, I switched to it later. It doesn't speed up a lot, but much better.
>> 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?
This is a good question. With simple configuration I have only file-based auth, no PAM. I would like to have one authenticator for system-wide services such as ssh and LuCI with it's RPC. I didn't see any evidence of PAM support in LuCI. But I might not look well through the code.
>> 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?
Right.
>
>> 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.
Thanks, I'll try.
--
Anton D. Kachalov
_______________________________________________
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