mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-20 12:38:08 +00:00
The purpose of SegmentedPool was pointer-stable values for the pty write path, and the std.MemoryPool provides that. SegmentedPool is actually so old it predates a stdlib memory pool! Just noting why I did it in the first place. I also wrote it when I was pretty fucking bad at Zig, so I'm shocked its lasted this long. The write path is hot , so the replacement was benchmarked against the old SegmentedPool plus a rewrite simple Pool I did before realizing... wait... why not just a MemoryPool. Benchmarked using the real 240-byte xev write request. workload old std.MemoryPool depth-1 (keystroke echo) 3.93 ns/op 0.96 ns/op burst (1MiB paste, d=256) 4.27 ns/op 1.00 ns/op cold growth (32 -> 16k) 4.54 ns/op 6.48 ns/op malloc create/destroy 15.9 ns/op (baseline) Cold growth is slower but this is only a cost when the pool grows. Note this also gets rid of the preallocation, which didn't show any measurable performance benefit at all. This has the benefit of shrinking our ThreadData by ~10KB.