Login
You're viewing the ruby.social public feed.
  • Nov 5, 2026, 7:02 PM

    You should be able to annotate a Lua interpreter such that it specializes every chunk of code it compiles, I think. You _might_ be able to tell it to use wasm locals, but idk, my memory of the lua API is that it's _incredibly_ stack oriented and there's no obvious concept of a base pointer. I'll have to dig into the VM itself a bit. Coroutines might screw with things too, not sure.

    💬 1🔄 0⭐ 0

Replies

  • Nov 6, 2026, 3:49 AM

    Today I convinced nix to produce a WASI-compatible PUC Lua build with clang. nixpkgs' cross-compilation support made this fairy simple, though as always nix's documentation is terrible, and it took a bunch of false starts before I figured out how to actually do it. Now I get to do the fun part.

    💬 1🔄 0⭐ 0
  • 💬 2🔄 0⭐ 0
  • Nov 8, 2026, 12:54 AM

    I have figured out how to use "wizer" to create a .wasm module where Lua has been preinitialized and a benchmark program has been loaded and compiled down to bytecode, and will immediately start executing when "main" is called. Once I've annotated the interpreter, this is what will get passed to "weval" for partial evaluation shenanigans.

    💬 1🔄 0⭐ 0
  • Nov 8, 2026, 1:21 AM

    The particular suite of Lua benchmarks I turned up also checks timings for LuaJITs non-JIT mode, which I forgot existed... I suspect LuaJIT's interpreter would be a _much_ better target for this than PUC Lua, because LuaJIT optimizes the data structure for tables and only turns into a generic hashtable and dispatches to metatables when absolutely necessary. Make optimisations like _that_ visible to the partial evaluator and you're _really_ cooking.

    💬 1🔄 0⭐ 0
  • Nov 12, 2026, 3:36 AM

    I have coerced the benchmark runner into running my .wasm modules and producing this nice graph as part of a nix build. Very strange to me that lua-5.5.1-wasm (the normal Lua interpreter) seems to often measure noticably faster than lua-5.5.1-wizer (a .wasm file running exactly the same interpreter, except the source code already loaded and compiled to bytecode, ready to be executed)

    Pushed what I've got so far (which is mostly nix code) to my forgejo: git.information-superhighway.n

    A colourful graph with "Elapsed time" on the Y axis running from 0 to 4.5 seconds, and an unlabeled X axis that corresponds to 13 benchmark programs run on 6 different Lua interpreters (lua-5.5.1-native, luajit-2.1, luajit-2.1-interp, lua-5.5.1-wasm, lua-5.5.1-wizer, lua-5.5.1-weval).
luajit-2.1 is the fastest on every benchmark, followed by luajit-2.1-interp and lua-5.5.1-native. lua-5.5.1-wasm / lua-5.5.1-wizer / lua-5.5.1-weval cluster around last place.
    💬 1🔄 0⭐ 0
  • Nov 6, 2026, 5:07 PM

    @SpindleyQ I didn't read the whole thread here but the "recompiled" retro game ports that have been happening work this way-- they translate machine code disassembly to C code. it is not LLM it is normal lovely healthy determinism

    💬 1🔄 0⭐ 0
  • Nov 6, 2026, 5:09 PM

    @SpindleyQ transcoding like this is so interesting to me. I enjoy doing it by hand as well as it is a very strange kind of refactoring (e.g. paste some C code into a .lua file and line by line make it Lua)

    💬 0🔄 0⭐ 0
  • Nov 7, 2026, 8:01 PM

    @PsySal it's really fascinating to me, because the theory of automatically deriving a compiler from an interpreter is from the 1970s, and it's actually pretty unreasonably effective, but in practice it's a very fringe idea, only a handful of "production-ready" language implementations work in this sort of way, and all the ones I know of (GraalVM, Pypy) are fairly modern and still kinda feel experimental.

    💬 1🔄 0⭐ 0
  • Nov 7, 2026, 8:36 PM

    @PsySal a modern JavaScript interpreter is like four different interpreters in a trenchcoat, that all make different performance tradeoffs and need to be kept in sync with each other by hand, and the whole sprawling nightmare is just kind of accepted as "well there's lots of JavaScript that needs to run fast so it's worth the investment"

    But like... If there's a technique where you can get 50% of the way there with, like, 0.0001% of the effort?? Woah Nelly sign me up, I want THAT

    💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0