mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-28 01:51:43 +00:00
terminal: bound page map probe lengths
#13292 Page maps previously allowed a 100% load factor. Once live entries and tombstones filled every slot, a missing-key lookup or insertion could scan the entire map. Reserve 20% of each offset hash map as insertion headroom and track that budget separately from the live count. Port the allocation-free in-place rehash from Zig HashMapUnmanaged so canonical insertion can rebuild fragmented probes and restore tombstone-exhausted headroom without growing the page. Assumed-capacity insertion now applies the same guard, preventing the headroom counter from wrapping. Pass the exact requested hyperlink count into map layout before load-factor scaling, avoiding a redundant power-of-two rounding step. Screen-level recovery now grows only when live hyperlinks actually fill usable capacity. ReleaseFast terminal benchmarks compare main with the combined map changes: | workload | before | after | speedup | |---|---:|---:|---:| | map churn | 1.253 s | 12.5 ms | 100x | | full OSC 8 stream | 3.576 s | 75.6 ms | 47x | | clear and redraw | 299.1 ms | 118.3 ms | 2.5x | Co-authored-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
@@ -20,7 +20,7 @@ pub const Id = size.HyperlinkCountInt;
|
||||
// The mapping of cell to hyperlink. We use an offset hash map to save space
|
||||
// since its very unlikely a cell is a hyperlink, so its a waste to store
|
||||
// the hyperlink ID in the cell itself.
|
||||
pub const Map = AutoOffsetHashMap(Offset(Cell), Id);
|
||||
pub const Map = AutoOffsetHashMap(Offset(Cell), Id, 80);
|
||||
|
||||
/// A fully decoded hyperlink that may or may not have its
|
||||
/// memory within a page. The memory location of this is dependent
|
||||
|
||||
Reference in New Issue
Block a user