renderer/metal: log some cache info

This commit is contained in:
Mitchell Hashimoto
2024-05-01 19:49:22 -07:00
parent 406824bcd4
commit 74236d2db6
2 changed files with 15 additions and 1 deletions

View File

@ -16,6 +16,8 @@ const Allocator = std.mem.Allocator;
const font = @import("../main.zig");
const lru = @import("../../lru.zig");
const log = std.log.scoped(.font_shaper_cache);
/// Our LRU is the run hash to the shaped cells.
const LRU = lru.AutoHashMap(u64, []font.shape.Cell);
@ -53,10 +55,17 @@ pub fn put(
) Allocator.Error!void {
const copy = try alloc.dupe(font.shape.Cell, cells);
const gop = try self.map.getOrPut(alloc, run.hash);
if (gop.evicted) |evicted| alloc.free(evicted.value);
if (gop.evicted) |evicted| {
log.debug("evicted shaped cells for text run hash={}", .{run.hash});
alloc.free(evicted.value);
}
gop.value_ptr.* = copy;
}
pub fn count(self: *const Cache) usize {
return self.map.map.count();
}
test Cache {
const testing = std.testing;
const alloc = testing.allocator;

View File

@ -1849,6 +1849,11 @@ fn rebuildCells(
x += if (cp.wide) 2 else 1;
}
}
// Log some things
log.debug("rebuildCells complete cached_runs={}", .{
self.font_shaper_cache.count(),
});
}
fn updateCell(