mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
perf(RefCountedSet): make swap metric prioritize high refcount items
This experimentally yields a ~20% performance improvement as measured by running DOOM-fire-zig, which is honestly a lot more than I expected.
This commit is contained in:
@ -607,8 +607,16 @@ pub fn RefCountedSet(
|
||||
break;
|
||||
}
|
||||
|
||||
// This item has a lower PSL, swap it out with our held item.
|
||||
if (item.meta.psl < held_item.meta.psl) {
|
||||
// If this item has a lower PSL, or has equal PSL and lower ref
|
||||
// count, then we swap it out with our held item. By doing this,
|
||||
// items with high reference counts are prioritized for earlier
|
||||
// placement. The assumption is that an item which has a higher
|
||||
// reference count will be accessed more frequently, so we want
|
||||
// to minimize the time it takes to find it.
|
||||
if (item.meta.psl < held_item.meta.psl or
|
||||
item.meta.psl == held_item.meta.psl and
|
||||
item.meta.ref < held_item.meta.ref)
|
||||
{
|
||||
// Put our held item in the bucket.
|
||||
table[p] = held_id;
|
||||
held_item.meta.bucket = p;
|
||||
|
Reference in New Issue
Block a user