# Rat's register allocator: a 584-line priority bin-packing allocator that beats its 1392-line predecessor

> Hacker News story 50030470 · language: en · submitted 2026-10-10
> Web version: https://zeli.app/story/50030470
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 68 · by [mpweiher](<https://news.ycombinator.com/user?id=mpweiher>) · 💬 4
[original](<https://hexrat.cc/pages/blog/2026_10_07>) · [HN discussion](<https://news.ycombinator.com/item?id=50030470>)

## Summary

Rat, a compiler backend, replaced its 1392-line linear scan allocator with a 584-line priority bin-packing allocator. The new allocator visits live ranges by importance, assigns registers to bundles, and spills when necessary. It produces better code, automatically placing values that cross calls into callee-saved registers without explicit rules. The design omits eviction, splitting, and iterative passes, yet measurements show minimal loss.

## Key quote

> No code in the allocator says "put values that cross a call in callee-saved registers". It falls out of the design, and that is my favourite part.

---

## Cite

- Page: https://zeli.app/story/50030470
- Date: 2026-10-10
- Source: hexrat.cc (https://hexrat.cc/pages/blog/2026_10_07)
- Hacker News: https://news.ycombinator.com/item?id=50030470

## Other languages

- zh: https://zeli.app/zh/story/50030470 · markdown: https://zeli.app/zh/story/50030470.md
- ja: https://zeli.app/ja/story/50030470 · markdown: https://zeli.app/ja/story/50030470.md
- ko: https://zeli.app/ko/story/50030470 · markdown: https://zeli.app/ko/story/50030470.md
- de: https://zeli.app/de/story/50030470 · markdown: https://zeli.app/de/story/50030470.md
- es: https://zeli.app/es/story/50030470 · markdown: https://zeli.app/es/story/50030470.md
- ru: https://zeli.app/ru/story/50030470 · markdown: https://zeli.app/ru/story/50030470.md
