Commit f948d42
authored
termio: replace SegmentedPool with std.MemoryPool (ghostty-org#13659)
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.
This was motivated by ghostty-org#136553 files changed
Lines changed: 28 additions & 119 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
418 | 417 | | |
419 | 418 | | |
420 | 419 | | |
421 | | - | |
422 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | | - | |
465 | | - | |
| 464 | + | |
| 465 | + | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
481 | | - | |
| 479 | + | |
| 480 | + | |
482 | 481 | | |
483 | 482 | | |
484 | 483 | | |
| |||
492 | 491 | | |
493 | 492 | | |
494 | 493 | | |
495 | | - | |
496 | | - | |
497 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
498 | 509 | | |
499 | 510 | | |
500 | 511 | | |
| |||
506 | 517 | | |
507 | 518 | | |
508 | 519 | | |
509 | | - | |
| 520 | + | |
510 | 521 | | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
| 522 | + | |
515 | 523 | | |
516 | 524 | | |
517 | 525 | | |
| |||
541 | 549 | | |
542 | 550 | | |
543 | 551 | | |
544 | | - | |
| 552 | + | |
545 | 553 | | |
546 | 554 | | |
547 | | - | |
548 | | - | |
| 555 | + | |
549 | 556 | | |
550 | 557 | | |
551 | 558 | | |
| |||
0 commit comments