It compiles each database query in about 5 millionths of a second.
Outside your usual reading: this is a technical walkthrough of writing a compiler, but it is a clean, concrete example of AI collapsing a rare, specialist skill into something one engineer could do himself.
The engineer, building a database project called pgrust, says a JIT compiler (one that turns code into fast machine instructions while the program is running, "just in time," rather than ahead of time) used to require knowing how to write assembly, the lowest-level code a chip actually runs, by hand. That skill is so rare that no production database today has built its own JIT compiler. They all lean on a general-purpose compiler toolkit called LLVM, or generate C/C++ code and compile that, and both routes are slow to compile, which limits how often they can be used. With AI assistance, he says it became "much easier than I expected" to target assembly directly with fast compile times, and he thinks this is now an open opportunity for new databases to beat older ones on.
The number that makes the case: his JIT compiler compiles code in about 5 microseconds (5 millionths of a second), fast enough that pgrust can JIT-compile every single database query it runs, not just a slow subset the way older systems do. JIT compilation typically buys a 2 to 5 times speed gain, sometimes more, in cases where the program does not know how it needs to behave until it is actually running, such as a language interpreter reading code for the first time, or a data parser that does not know the shape of the data until it sees it.
To show the mechanism, he builds a small example: a search-pattern engine, a "regex" (short for regular expression, a way of describing a pattern to match in text), that supports only literal text and one repeat operator, nothing fancier. The toy engine has three building blocks: a literal string match, a "repeat this part zero or more times" block, and a way to join two blocks in sequence. That is enough to match patterns like "apples" or "b(an)*" (the letter b followed by "an" repeated any number of times, including zero), though it skips harder features like matching one of several options or checking what came before a position. The interpreter version of this is short and works correctly, which is exactly why the slowdown against hand-written code for the same pattern, 10 to 20 times, is the more interesting number: correctness was never the hard part, speed was.
The technique that closes that gap is called "copy-and-patch." You keep a library of small, already-compiled chunks of assembly for each basic operation, called "stencils," the way a stencil is a physical template you trace around. To compile a specific pattern, you take the matching stencils, fill in the details specific to that instance, almost literally like filling in a stencil, and glue the filled-in chunks together into one program at the moment you need it. Strung together this way, the generated code runs close to hand-written speed, because it mostly is hand-written speed, just assembled automatically. The recipe has two parts: first generate the assembly instructions, then copy those instructions into a block of memory the program is allowed to execute, so the rest of the code can call the result exactly like calling any other function. His plan for the rest of the piece walks through the actual ARM64 (the chip design used in modern Macs and phones) instructions for the example pattern, turns the repeated instruction patterns into reusable stencils, writes the code that fills and strings them together from the parsed pattern, and copies the finished instructions into memory that Rust, the language pgrust is written in, can call directly.
The piece cuts off mid-explanation of that last step in the version saved here, but the shape of the argument already holds: a task that used to gate who could even attempt it, hand-written assembly, is now something AI assistance gets an individual engineer through, and it shows up as a real, measured number, 5 microseconds, not just a claim.