alt.hn

3/18/2026 at 9:26:23 PM

ZJIT removes redundant object loads and stores

https://railsatscale.com/2026-03-18-how-zjit-removes-redundant-object-loads-and-stores/

by tekknolagi

3/21/2026 at 5:53:05 PM

Of all the facets of HN’s title autodestroy, I think removing “How” from titles is the worst one. I believe OP can edit it back in though.

(I passed over this article thinking it was a “look how mysteriously smart the mysteriously smart compiler is” acticle, not a “here’s how the smarts in a compiler work” one.)

by mananaysiempre

3/21/2026 at 9:02:05 PM

I think it'd fine having it be however broken it currently is as long as the correction was checked by whoever is submitting the entry before it gets published.

by dietr1ch

3/21/2026 at 7:36:00 PM

Yes, there is a timeout to fix title "corrections" after submission, but apparently still not well known.

by pjmlp

3/21/2026 at 9:18:28 PM

Not well known and also, submitter might not always even notice that title was automatically changed slightly.

by QuantumNomad_

3/22/2026 at 5:17:04 AM

I'm working on an interpreter right now, and I'm considering adding JIT support in the future. Are there other blog posts like this, or deep dives that talk about how to implement and tune a JIT?

by smj-edison

3/22/2026 at 5:28:34 AM

I used asmjit to implement JIT compilation. Highly recommend it.

Maybe you'll find the resources I link to in the documentation for my project helpful.

https://github.com/ZQuestClassic/ZQuestClassic/blob/main/doc...

Or perhaps you'd find reviewing my usage of asmjit helpful:

https://github.com/ZQuestClassic/ZQuestClassic/blob/main/src...

My main high-level advice would be to have an extensive set of behavioral tests (lots of scripts with assertions on the output). This helps ensure correctness when you flip on your JIT compilation.

You'll eventually run into hard to diagnose bugs - so be able to conditionally JIT parts of your code (per-function control - or even better, per-basic block) to help narrow down problem areas.

The other debugging trick I did was spit out the full state of the runtime after every instruction, and ensure that the same state is seen after every instruction even w/ JIT enabled.

Good luck!

by hoten

3/22/2026 at 3:01:07 AM

The escape analysis piece is what makes this particularly interesting. ZJIT can prove an object doesn't escape a method's scope and then eliminate the heap allocation entirely — the object lives on the stack (or in registers) and the load/store optimizations follow naturally once there's no indirection.

YJIT's profile-guided approach is powerful but pays a cost every time a hot path diverges from the expected type. The BBV approach in ZJIT bakes type assumptions directly into the compiled code, so you get the same specialization without the deopt overhead on the happy path. The tradeoff is code size — more type combinations means more compiled variants — but for server-side Rails apps where the method profile is fairly stable, that's usually fine.

Curious whether they're planning to share any of the escape analysis machinery upstream to YJIT, or if the JIT designs are diverging permanently.

by diablevv

3/22/2026 at 6:56:35 AM

LLM comment history.

by AlexeyBelov

3/22/2026 at 7:24:48 PM

Yup! Clanker confirmed.

I used the sophisticated LLM detection technique called "I wrote this blog post and I wish we had escape analysis in ZJIT too."

by noescapeyet

3/22/2026 at 12:22:59 PM

Indeed, I see they now wait 28 days to not been displayed in green before commenting.

by Rexxar

3/21/2026 at 7:54:46 PM

for me is more interesting that Maxime Chevalier-Boisvert left shopify and is doing other stuff, who will carry on with zjit

by claudiug

3/21/2026 at 8:25:47 PM

Max Bernstein is now leading the team. He's also an excellent compiler engineer.

by maxime_cb

3/21/2026 at 9:21:54 PM

that is great to hear!

by claudiug

3/21/2026 at 10:25:23 PM

You got your reply already. To add: YJIT is the one that does "basic block versioning" (Which was Maxime's thesis) while ZJIT is a more traditional design.

I am confident in that description but don't actually know what it means in practice (yes I've seen papers and talks, but I kinda need not-compiler-engineer to explain it to me.)

As I understand it BBV still holds promise, but the sheer volume of knowledge of more traditional methods might mean it gets better outcomes (also IIRC ZJIT is still lagging YJIT).

by schneems

3/22/2026 at 2:52:22 AM

I gave a talk about ZJIT and the motivation for the change at RubyKaigi 2025 if people are curious. It's on YouTube.

by maxime_cb

3/21/2026 at 10:28:54 PM

> IIRC ZJIT is still lagging YJIT

It would be nice to have ZJIT on speed.ruby-lang.org!

by riffraff

3/22/2026 at 12:45:48 PM

She's at yasp since Nov 25. Probably earning much more than at Shopify, and can do AI

by rurban

3/21/2026 at 6:05:57 PM

curious if zjit will be ready to be default over yjit next ruby release. hope so!

by mchusma

3/21/2026 at 9:00:37 PM

[dead]

by riteshyadav02