If you're interested in "how" or "why": the major culprit is that each row in Alacritty has 32 bytes of metadata and each cell is 24 bytes. In Ghostty, every row and cell is represented by exactly 8 byte each. How do we do this?
The first major culprit is styles. Alacritty stores the full cell style alongside each cell (foreground, background, underline, etc.). Ghostty stores a 16-bit style ID and de-dupes all styles into a look-aside custom reference-counted hash table.
MOST cells are unstyled, and when there are styles MOST styles are shared, and when styles are shared MOST are repeated in a run (multiple cells with the same style in a row). Put this all together, and the tradeoff on compute to access it doesn't even end up being slower.
Next, codepoints. Alacritty stores multi-codepoint graphemes (like, Emoji) by having an 8-byte nullable pointer to a `Vec<char>`. This hurts doubly: (1) its almost always null (because multi-codepoint is rare) yet you pay an 8 byte cost on every cell and (2) every multi-codepoint grapheme triggers a heap allocation to make that Vec.
Ghostty stores single codepoints inline, but multiple codepoints in a look-aside table. The memory for this table uses a custom bitmap-tracked chunk-allocator (since grapheme frequency follows a measurable curve we calculated by scanning various online texts). The presence of graphemes is marked by a 2-bit content tag in our packed 64-bit cell. To keep the key small in the hash table, its limited to a 16-bit unsigned int that is an offset from a base pointer.
Okay, the astute systems programmer will quickly notice there are a lot of 16-bit integers and ask: so this is all limited to a max of ~65K values?
Nay. We maintain our grid using a linked list of contiguous ~400KB memory chunks (which themselves are in a memory pool using a custom allocator to speed up alloc/free). Each memory chunk is limited to 2^16. If/when we reach a limit, we move to the next page. In practice, this really doesn't happen except under pathological cases... the important point is we handle it.
Lots, lots, lots more details, but thats a 10,000 foot view.
These things alone account for ~95% of the difference of our uncompressed vs. Alacritty's uncompressed memory usage. (Theres also a reason why Alacritty's data structures aren't trivially compressable but thats a whole other topic)
Atlas, our AI vulnerability research system, is now ranked #1 on CyberGym. We've used it to discover and responsibly disclose more than 200 confirmed vulnerabilities across gVisor, Linux kernel, containerd and many other projects.
Here’s how Atlas works behind the scenes 🧵
libghostty vs. Alacritty (alacritty_terminal crate) memory usage. This tests pure terminal state with various payloads: empty screen, full screen, 10K row scrollback with plain text, unicode, heavy styling, and mixed. This is the most accurate read to what an embedder sees.
So, when you see meme posts about Ghostty (or any of its embedders) memory usage, that is the fault of the application. Ghostty GUI itself certainly has some memory bloat! But its the GUI apps causing this, not libghostty.
Note that Ghostty's results include our active scrollback compression, which Alacritty doesn't support. This is fair because it is on by default and happens automatically (while we still have higher IO throughput than Alacritty). It is the proper like-for-like comparison because it's what you'd experience.
I included uncompressed numbers too though even though you'd have to actively try to get these, just to show even uncompressed is significantly better.
Also, these were all run within the same Rust-written binary that embeds both, so it also avoids measuring the binary overhead differently since they run from an identical binary.
I'm working on also measuring libvte and writing a longer form blog post to share the whole testing setup. I needed something to link to whenever I see the memes.
libghostty is small, nimble, and excellent software.
If that OAI model that hacked HF were open weight, anyone with a few chips could run it safeguard free! If OAI fixes the alignment, anyone with a few more chips could tune the alignment out!
Yes, anyone can identify vulnerabilities! And if a16z commits to patching every hospital
@ruima@ThingsHiddenn@chontang For example, they'll ask you what you think about open weight models and reject you if your answer isn't "open models are evil"
@mooncat_is Ha yes, "a few chips."
I'm sure NO ONE would be able to trace down the one guy who bought a full datacenter to run his clankers.
This clownery needs to stop.
Anthropic isn't the good corp in this game. You just live in a cultish echo chamber.