PowerDNS / pdns

PowerDNS Authoritative, PowerDNS Recursor, dnsdist
https://www.powerdns.com/
GNU General Public License v2.0
3.7k stars 908 forks source link

Please document how to compile lua scripts for the recursor #12972

Open Popyllol opened 1 year ago

Popyllol commented 1 year ago

Short description

Hi PowerDNS-Team, When I just do a: luac -o lua-script.compiled lua-script to compile it (btw. without any errors). After starting the recursor again I just can see:

Failed to load 'lua' script from 'etc/powerdns/lua-script.compiled': chunk: cannot load incompatible bytecode I tried luac5.4 and luac5.3. The uncompiled lua script runs without problems.

So I searched the docs and found nothing except:

8.1 Configuring Lua scripts
...
Note: It is also possible to precompile scripts using luac, and have PowerDNS load the result. This means that
switching scripts is faster, and also that you’ll be informed about syntax errors at compile time.

Some mor details on compiling would be nice. Thank you, Lars

Usecase

Getting more performance while running the recursor in a high load environment.

Description

rgacogne commented 1 year ago

Hi,

You have unfortunately removed the part of our template that ask which version you use, if you compiled it yourself or installed from a package repository, and which repository in that case. So I'm going to have to guess that your recursor is compiled against LuaJIT, and thus is not compatible with the bytecode obtained from luac. In my experience LuaJIT just-in-time compilation yields better performance than using pre-compiled code with Lua, but YMMV.

Zash commented 1 year ago

cannot load incompatible bytecode

FWIW, this appears to be the LuaJIT error when attempting to load PUC-Rio Lua 5.x bytecode

Habbie commented 1 year ago

Should we remove the luac note from the docs? Or at least add some more explanation/warning to it? I also wonder if it's really worth any speedup (but the syntax check is nice, of course)

Zash commented 1 year ago

Given that e.g. on Debian it's possible to have five different Lua implementations installed at the same time, and LuaJIT doesn't have luac, IIRC you do luajit -b raw instead, plus having to know which Lua variant pdns is using ... writing clear instructions might be a challenge.

Popyllol commented 1 year ago

luajit worked for me on Ubuntu. Thanks a lot. A little more documentation about compiling lua and how big the benefit might be or not would be nice. It looks like the benefit in our case is very little as we just blow up the log with some more informations. Greetings, Lars