Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    H

    Haoran Xu

    sillycross.github.io · Personal blog · on HN since 2021

    Haoran Xu writes about building fast Lua interpreters and JITs automatically, plus C++ tricks and low-level performance debugging.

    Visit blogHN submissions
    Languages & CompilersSystems & Performance
    What HN says

    Commenters link his Lua interpreter work and copy-and-patch posts as impressive, and discuss how a generated interpreter can beat hand-written assembly.

    Stats for nerds
    32HN people shared it
    27linked in comments
    775story points
    Apr 2026last shared
    2023people per year2026

    Top posts on HN

    1. 1
      Building the fastest Lua interpreter automatically
      9 people · 561 points · first shared 2022 · 109 comments on HN
    2. 2
      Building a baseline JIT for Lua automatically (2023)
      14 people · 146 points · first shared 2023 · 29 comments on HN
    3. 3
      CookUnity fabricated an order with random items and charged my credit card
      1 person · 26 points · first shared 2021 · 18 comments on HN
    4. 4
      A Trick for Reflection in C++
      3 people · 15 points · first shared 2021 · 2 comments on HN
    5. 5
      Microbenchmarking is hard: how an innocent printf caused a drastic slowdown
      2 people · 12 points · first shared 2021 · 1 comments on HN
    6. 6
      Understanding a static analysis pass in JavaScriptCore JIT
      1 person · 7 points · first shared 2021 · 2 comments on HN
    7. 7
      Bizarre performance characteristics of Alder Lake CPUs
      2 people · 3 points · first shared 2022 · Discussion on HN
    8. 8
      Building the fastest Lua interpreter.. automatically
      2 people · 2 points · first shared 2022 · 1 comments on HN
    9. 9
      Debugging a Bit-Flip Error
      2 people · 2 points · first shared 2023 · Discussion on HN
    10. 10
      A Trick for Reflection in C++
      2 people · 1 points · first shared 2023 · 1 comments on HN

    What HN people wrote when they linked it

    • vanderZwanJan 2024

      I think it's really cool that Haoran Xu and Fredrik Kjolstad's copy-and-patch technique[0] is catching on, I remember discovering it through Xu's blog posts about his LuaJIT remake project[1][2], where he intends to apply these techniques to Lua (and I probably found those through a post here). I was just blown away by how they "recycled" all these battle-tested techniques and technologies, and used it to synthesize something novel. I'm not a compiler writer but it felt really clever to me.

      I highly recommend the blog posts if you're into learning how languages are implemented, by the way. They're incredible deep dives, but he uses the details-element to keep the metaphorical descents into Mariana Trench optional so it doesn't get too overwhelming.

      I even had the privilege of congratulating him the 1000th star of the GH repo[3], where he reassured me and others that he's still working on it despite the long pause after the last blog post, and that this mainly has to do with behind-the-scenes rewrites that make no sense to publish in part.

      [0] https://arxiv.org/abs/2011.13127

      [1] https://sillycross.github.io/2022/11/22/2022-11-22/

      [2] https://sillycross.github.io/2023/05/12/2023-05-12/

      [3] https://github.com/luajit-remake/luajit-remake/issues/11

    • sitkackNov 2024

      > We implement LuaJIT Remake (LJR), a standard-compliant Lua 5.1 VM, using Deegen. Across 44 benchmarks, LJR's interpreter is on average 179% faster than the official PUC Lua interpreter, and 31% faster than LuaJIT's interpreter. LJR's baseline JIT has negligible startup delay, and its execution performance is on average 360% faster than PUC Lua and only 33% slower (but faster on 13/44 benchmarks) than LuaJIT's optimizing JIT.

      presentation by the author

      Deegen: A LLVM-based Compiler-Compiler for Dynamic Languages https://www.youtube.com/watch?v=5cAUX9QPj4Y

      Slides https://aha.stanford.edu/sites/g/files/sbiybj20066/files/media/file/aha_071923_xu_deegen_0.pdf

      Ongoing work documented here https://sillycross.github.io/ and some comments here https://lobste.rs/s/ftsowh/building_baseline_jit_for_lua

      https://github.com/luajit-remake/luajit-remake

    • MatthiasPortzelApr 2025

      It's crazy that this post seems to have stumbled across an equivalent to the Copy-and-Patch technique[0] used to create a Lua interpreter faster than LuaJit[1]

      [0]: https://sillycross.github.io/2023/05/12/2023-05-12/ [1]: https://sillycross.github.io/2022/11/22/2022-11-22/

      The major difference is that LuaJIT Remake's Copy-and-Patch requires "manually" copying blocks of assembly code and patching values, while this post relies on the Go compiler's closures to create copies of the functions with runtime-known values.

      I think there's fascinating processing being made in this area—I think in the future this technique (in some form) will be the go-to way to create new interpreted languages, and AST interpreters, switch-based bytecode VMs, and JIT compilation will be things of the past.

    • gavinrayApr 2026

      It doesn't make sense to me that an embedded VM/interpreter could ever outperform direct code

      You're adding a layer of abstraction and indirection, so how is it possible that a more indirect solution can have better performance?

      This seems counterintuitive, so I googled it. Apparently, it boils down to instruction cache efficiency and branch prediction, largely. The best content I could find was this post, as well as some scattered comments from Mike Pall of LuaJIT fame:

      https://sillycross.github.io/2022/11/22/2022-11-22/

      Interestingly, this is also discussed on a similar blogpost about using Clang's recent-ish [[musttail]] tailcall attribute to improve C++ JSON parsing performance:

      https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html

    • sillycrossDec 2023

      > I just meant that even being aware this is a naive copy-and-patch JIT, my first impression was that the code was slightly worse than I expected.

      > "there’s only so much one can do without touching the data model"

      You probably want to look at the other link in that PR, which demonstrated how well copy-and-patch can do for another dynamic language (Lua): [1]

      Of course, whether or not CPython could eventually make it to that point (or even further) is a different story: they are under a way tighter constraint than just developing something for academia. But copy-and-patch can do a lot even for dynamic languages :)

      [1] https://sillycross.github.io/2023/05/12/2023-05-12/

    • mananaysiempreNov 2024

      > we might conclude that the speed-up of a manual assembler implementation compared to a generated interpreter is about 30%[, t]herefore it's no longer worth the effort to implement an interpreter in assembler

      You got that backwards. The paper reports Deegen’s generated interpreter is faster than LuaJIT’s handwritten one by 30%. That’s actually pretty impressive—and pretty impressively straightforwardly achieved[1], TL;DR: instruction dispatch via tail calls avoids the pessimized register allocation that you get for a huge monolithic interpreter loop.

      [1] https://sillycross.github.io/2022/11/22/2022-11-22/

    Related

    Josh Habermanblog.reverberate.org105 people

    Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Calls in C

    Josh Haberman
    Personal · last shared 2026
    Erik Engheimerik-engheim.medium.com29 people

    Why is Apple's M1 chip so fast?

    Erik Engheim
    Personal · last shared 2026
    Philippe Gaultiergaultier.github.io23 people

    You've just inherited a legacy C++ codebase, now what?

    Philippe Gaultier
    Personal · last shared 2026
    Haki Benitahakibenita.com52 people

    Lesser-known Postgres features

    Haki Benita
    Personal · last shared 2026
    Dan Luudanluu.com1.2k people

    We only hire the trendiest

    Dan Luu
    Personal · last shared 2026
    Futhark Blogfuthark-lang.org87 people

    Designing a Programming Language for the Desert

    Futhark Blog
    Company · last shared 2026
    IT Hareithare.com80 people

    Operation Costs in CPU Clock Cycles

    IT Hare
    Personal · last shared 2026
    Pointers Gone Wildpointersgonewild.com88 people

    The internet changed my life

    Pointers Gone Wild
    Personal · last shared 2026