Files
ghostty/src/termio
Mitchell Hashimoto e0ef934f73 termio: replace SegmentedPool with std.MemoryPool
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.
2026-08-05 20:58:33 -07:00
..