<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow.]]></title><description><![CDATA[<p>C interpreters underlie many of our most widely used language implementations -- but they're slow. Wouldn't it be great if we could turn them into JIT compiling VMs? This video shows what happens when we do just that to the normal Lua VM (first) and "yklua" (Lua w/JIT, second).</p>

<div class="row mt-3"><div class="col-12 mt-3"><div class="ratio ratio-16x9">
<video controls width="1636" height="1200">
<source src="https://files.mastodon.social/media_attachments/files/116/408/544/848/618/738/original/cbb50734acf885be.mp4" type="video/mp4"></source>
</video>
</div></div></div>]]></description><link>https://board.circlewithadot.net/topic/1de4275a-4431-4004-bcbc-7e837fdf5136/c-interpreters-underlie-many-of-our-most-widely-used-language-implementations-but-they-re-slow.</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 06:45:40 GMT</lastBuildDate><atom:link href="https://board.circlewithadot.net/topic/1de4275a-4431-4004-bcbc-7e837fdf5136.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Apr 2026 11:51:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:27:17 GMT]]></title><description><![CDATA[<p><span><a href="/user/david_chisnall%40infosec.exchange">@<span>david_chisnall</span></a></span> A very early prototype of yk used LLVM for these purposes, but the compilation performance was awful (from memory something like 1000x worse than we needed). It's not really LLVM's fault though: we were feeding it an input it never expected to see. [We also encountered multiple threading bugs, but I imagine those have been fixed in the interim.]</p>]]></description><link>https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408715671225939</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408715671225939</guid><dc:creator><![CDATA[ltratt@mastodon.social]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:27:17 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:24:57 GMT]]></title><description><![CDATA[<p><span><a href="/user/david_chisnall%40infosec.exchange">@<span>david_chisnall</span></a></span> I assumed that LuaJIT did quite a good job with FFI performance (the API it defined has spread more widely), but I haven't benchmarked it! That said, there are some heuristics in LuaJIT that do not always play well with real-world code.</p><p>yklua will just do whatever PUC Lua does, but it will probably inline right up until the FFI call, which might help. That said, right now, you can still hit missing bits that tank performance in any yk interpreter, so it's difficult to say!</p>]]></description><link>https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408706501274859</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408706501274859</guid><dc:creator><![CDATA[ltratt@mastodon.social]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:24:57 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:21:07 GMT]]></title><description><![CDATA[<p><span><a href="https://mastodon.social/@ltratt">@<span>ltratt</span></a></span> iPhone, I’m not sure how to get error output so this is a terrible bug report</p>]]></description><link>https://board.circlewithadot.net/post/https://hachyderm.io/users/llimllib/statuses/116408691456100386</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://hachyderm.io/users/llimllib/statuses/116408691456100386</guid><dc:creator><![CDATA[llimllib@hachyderm.io]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:21:07 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:14:21 GMT]]></title><description><![CDATA[<p><span><a href="https://mastodon.social/@ltratt" rel="nofollow noopener">@<span>ltratt</span></a></span> </p><p>There's another approach that's worth mentioning, popularised by Apple's old shader JIT, which looks like a more ad-hoc version of what you've built.</p><p>Each operation was written as a function that took a pointer to the interpreter state and updated it.  The interpreter is then a big switch statement calling these functions.  These typically all get inlined so you end up with one massive function that runs in a loop.</p><p>To build the JIT, you compile those individual functions to LLVM IR, then JIT compile a function that is equivalent to the calls of a sequence of bytecode.  The normal LLVM optimisers can then inline small or infrequently-used opcode bodies, and optimise across the whole program (or whole function, trace, or whatever else you want to JIT).  The JIT'd code has the same interpreter state (though may update it only at the end of a trace - apparently marking it as not-aliasing-anything gets you around 10% extra performance), so you can JIT whatever size fragment makes sense.</p>]]></description><link>https://board.circlewithadot.net/post/https://infosec.exchange/users/david_chisnall/statuses/116408664829793299</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://infosec.exchange/users/david_chisnall/statuses/116408664829793299</guid><dc:creator><![CDATA[david_chisnall@infosec.exchange]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:14:21 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:09:28 GMT]]></title><description><![CDATA[<p><span><a href="/user/llimllib%40hachyderm.io">@<span>llimllib</span></a></span> Which browser? They work on my Android phone's browsers, but video compatibility beyond that is a bit of an unknown to me.</p>]]></description><link>https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408645586354468</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408645586354468</guid><dc:creator><![CDATA[ltratt@mastodon.social]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:09:28 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:06:45 GMT]]></title><description><![CDATA[<p><span><a href="https://mastodon.social/@ltratt">@<span>ltratt</span></a></span> the videos in your post are not working on my phone</p><p>(Cool work!)</p>]]></description><link>https://board.circlewithadot.net/post/https://hachyderm.io/users/llimllib/statuses/116408634939361709</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://hachyderm.io/users/llimllib/statuses/116408634939361709</guid><dc:creator><![CDATA[llimllib@hachyderm.io]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:06:45 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 12:04:46 GMT]]></title><description><![CDATA[<p><span><a href="https://mastodon.social/@ltratt" rel="nofollow noopener">@<span>ltratt</span></a></span> </p><blockquote><p>This hopefully makes the trade-off yk offers clear: yklua does not reach the performance peaks of the wonderful, carefully hand-written, LuaJIT</p></blockquote><p>For what it's worth:</p><p>In igk, I use sol3, which lets you select the Lua implementation as a build-time option.  I don't use any fancy new Lua features in this (64-bit integers are really important for some other things where I looked at Lua, but not for igk), so I tried both Lua and LuaJIT.  There wasn't much difference in terms of performance, but LuaJIT was a bit <em>slower</em> than the interpreter.</p><p>My guess is that this is primarily because FFI is slower with LuaJIT and my code did a <em>lot</em> of FFI (basically everything it's doing is calling back into C++ to manipulate the text tree).</p><p>I presume that yklua uses exactly the same memory layout as the C version, so I'd expect it to be better here.</p><p>This is also a problem with a lot of Python JITs: If you make Python faster and make CPython-compatible FFI slower, you generally make Python programs slower.</p>]]></description><link>https://board.circlewithadot.net/post/https://infosec.exchange/users/david_chisnall/statuses/116408627129753865</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://infosec.exchange/users/david_chisnall/statuses/116408627129753865</guid><dc:creator><![CDATA[david_chisnall@infosec.exchange]]></dc:creator><pubDate>Wed, 15 Apr 2026 12:04:46 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 11:54:59 GMT]]></title><description><![CDATA[<p>I want to say a big thanks to Shopify and the Royal Academy of Engineering who graciously funded this research. I'd like to dedicate this work to the late Chris Seaton, who was an early champion of yk: he is much missed by me and many others.</p>]]></description><link>https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408588685856038</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408588685856038</guid><dc:creator><![CDATA[ltratt@mastodon.social]]></dc:creator><pubDate>Wed, 15 Apr 2026 11:54:59 GMT</pubDate></item><item><title><![CDATA[Reply to C interpreters underlie many of our most widely used language implementations -- but they&#x27;re slow. on Wed, 15 Apr 2026 11:51:42 GMT]]></title><description><![CDATA[<p>This isn't just a technique for Lua, though -- it works for any C interpreter compilable with LLVM! More about how and why in this new post 'Retrofitting JIT Compilers into C Interpreters' looking at our new 'yk' system. <a href="https://tratt.net/laurie/blog/2026/retrofitting_jit_compilers_into_c_interpreters.html" rel="nofollow noopener"><span>https://</span><span>tratt.net/laurie/blog/2026/ret</span><span>rofitting_jit_compilers_into_c_interpreters.html</span></a></p>]]></description><link>https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408575747142348</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://mastodon.social/users/ltratt/statuses/116408575747142348</guid><dc:creator><![CDATA[ltratt@mastodon.social]]></dc:creator><pubDate>Wed, 15 Apr 2026 11:51:42 GMT</pubDate></item></channel></rss>