Building the fastest Lua interpreter.. automatically!
I have been working on a research project to make writing VMs easier. The idea arises from the following observation: writing a naive interpreter is not hard (just write a big switch-case), but writing a good interpreter (or JIT compiler) is hard, as it unavoidably involves hand-coding assembly. So why can’t we implement a special compiler to automatically generate a high-performance interpreter (and even the JIT) from “the big switch-case”, or more formally, a semantical description of what each bytecode does?
An unexpected Redis sandbox escape affecting only Debian, Ubuntu, and other derivatives
This post describes how I broke the Redis sandbox, but only for Debian and Debian-derived Linux distributions. Upstream Redis is not affected. That makes it a Debian vulnerability, not a Redis one. The culprit, if you will, is dynamic linking, but there will be more on that later.
More consistent LuaJIT performance
So, did we achieve everything we wanted to in 12 months? Inevitably the answer is yes and no. We did a lot more benchmarking than we expected; we’ve been able to make a lot of programs (particularly large programs) have more consistent performance; and we’ve got a fair way down the road of implementing a new GC. To whoever takes on further LuaJIT work – best of luck, and I look forward to seeing your results!
A Look at the Design of Lua
Lua has a unique set of design goals that prioritize simplicity, portability, and embedding. The Lua core is based on three well-known, proven concepts—associative arrays, first-class functions, and coroutines—all implemented with no artificial restrictions. On top of these components, Lua follows the motto “mechanisms instead of policies,” meaning Lua’s design aims to offer basic mechanisms to allow programmers to implement more complex features.
Reads like a short version of the Programming in Lua book.
Adventures in Lua stack overflows
If you’ve never used it before, Lua’s C API is designed to be very simple to integrate with other code, but it also places a fairly high burden on developers to integrate it properly.
I never thought the burden was high, rather convenient compared to other languages actually, but this is one potential trouble spot.
An Introduction to Urn
These tutorials aim to guide you through Urn, a Lisp dialect which compiles to Lua. We’ll assume you have some prior programming knowledge. A little Lua knowledge is useful in places, though not required.
Helping to make LuaJIT faster
This project will also naturally help us advance our wider research interests centred around understanding how VM performance can be improved. I’m hopeful that what we learn from LuaJIT will, in the long run, also help other VMs improve. Indeed, we have big ideas for what the next generation of VMs might look like, and we’re bound to learn important lessons from this project.
LuaJIT Hacking: Getting next() out of the NYI list
One of the first pieces of advice anyone receives when writing Lua code to run quickly using LuaJIT is “avoid the NYIs”: the language or library features that can’t be compiled because they’re NYI (not yet implemented). And that means they run in the interpreter.
A very long post with lots of details.
in which four pieces are placed in a row
Of course there’s a lot more that Polywell can do, but it doesn’t take much code to get a simple game going. Try it for yourself; you might have a lot of fun.
Lua: A Guide for Redis Users
More specifically a short intro to the Lua environment in Redis.