wasm_lua (wasm v0.16.0)
View SourceRun Lua from an image of an already-started interpreter.
The third language through the same profile, and the one that exists to be unlike the other two. QuickJS and CPython are large interpreters whose images run to hundreds of kilobytes and megabytes; Lua's holds about 77 KB, which is where a mechanism that quietly assumed bulk would show it.
{ok, W} = wasm_script_worker:start_link(
wasm_lua,
#{path => "test/fixtures/lang/lua_reactor.wasm",
limits => wasm_lua:limits()}),
{ok, #{result := #{~"answer" := 42}}} =
wasm_script_worker:run(W, #{source => <<"function main(c)"
" return {answer = c.value + 1} end">>,
context => #{~"value" => 41}}).The tenant writes a global main, because Lua has no module export syntax:
function main(context)
return {answer = context.value + 1}
endBuild the artifact with scripts/build-lua-reactor.sh and check what it is
against test/fixtures/lang/LUA.md.
What it demonstrates
Nothing in the kernel, the profile or the snapshot mechanism changed to admit
it. That is the acceptance rule in docs/worker-contract.md applied to a
language chosen after all three were written, and it is the only form of
evidence for neutrality that is worth anything.
The one thing it did need was a build flag: Lua signals errors with
longjmp, which on WebAssembly is exception handling, and LLVM still emits the
superseded encoding by default. LUA.md has it.
Summary
Functions
The heap floor a request runner starts with, unless the caller sets one.
What this guest needs. Modest, which is the point of it being here.
Functions
-spec defaults(map()) -> wasm_worker_adapter:defaults().
The heap floor a request runner starts with, unless the caller sets one.
200,000 words is the measured knee: a request fell from 30.0 ms and 98
collections to 12.7 ms and 23 (test/audit/PERF.md, "The 26 ms. Found: it is
the runner's own garbage collection"). It rounds up to 318,187 words, about
2.5 MB, held only while a request runs. No capture floor: the image is 77 KB
and the capture is not where the time goes.
The same number for both tiers. In a pool of ten workers it gave the compiled tier 13 to 18% more throughput and cut the collector's share of scheduler time from about 9% to 0.9%, and the interpreter 2.1 to 2.2x ("Default floors in a pool").
-spec limits() -> map().
What this guest needs. Modest, which is the point of it being here.