Repository navigation
Conversation
…ing it per terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This focuses explicitly on the non-mmap allocations for a
ghostty_terminal_newresult. The result is that we lower this portion of the memory by almost half. The total benefit is smaller since 70% of a terminal is mmap'd allocations, but this still yields an absolute ~5KB savings on macOS on every new terminal (not just empty, but also with a normal prompt and so on).Four changes to make it happy, broken down into individual commits. Nothing crazy:
std.heap.MemoryPool, which sits on an arena that preheats and grows 1.5x, so we paid for wasted space. Nodes now come fromUntouchedPool(the same pool as page buffers) with a preheat of one, so the cost is exactlyone node (well, exactly one bucket element size in whatever allocator).max_path_bytesbuffer that only embedders that setkitty_image_medium_temp_fileever wrote to.DynamicPalettecarried two full 1 KiB palettes,currentandoriginal, andoriginalwas almost always the built-in default. It is now a pointer to the shared built-in default, or to an allocator-owned copy when a custom default is set. This introduces a new OOM path but we gracefully handle it by either ignoring or resetting.Memory measurements:
terminal_newI ran
ghostty-bench +terminal-streamon a 500 MB ascii corpus, main vs this branch interleaved, and there is no noticeable change.AI usage: Fable did validation of the work, I did the implementations, commit messages, and PR notes.