From 98061003467dd8b927fd3c5a5199e4c5e7e13de1 Mon Sep 17 00:00:00 2001 From: Jesse Miller Date: Wed, 9 Sep 2026 12:30:09 -0600 Subject: [PATCH] Pack shaped run cache arenas in 4 KiB blocks I've been running with the shaped run cache and some extra logging, decided to bump to a 4KiB slab. The theoretical and actual waste do show up during use. My initial sizing was only a best guess based of glyph cache and a 32 cell run typically fitting just below a 2KiB slab. --- kitty/shaped-run-cache.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kitty/shaped-run-cache.c b/kitty/shaped-run-cache.c index 0f8f65c11..776019b2a 100644 --- a/kitty/shaped-run-cache.c +++ b/kitty/shaped-run-cache.c @@ -14,6 +14,7 @@ #define SHAPED_RUN_MAX_ENTRIES 2048u #define SHAPED_RUN_MAX_BYTES (1024u * 1024u) #define SHAPED_RUN_MA_BLOCK_SIZE 16u +#define SHAPED_RUN_SLAB 4096u typedef struct ShapedRunKey { uint32_t keysz_in_bytes; @@ -56,11 +57,12 @@ static bool shaped_run_map_cmpr(KEY_TY a, KEY_TY b); #define MA_NAME Key #define MA_BLOCK_SIZE SHAPED_RUN_MA_BLOCK_SIZE static_assert(MA_BLOCK_SIZE > sizeof(ShapedRunKey), "increase arena block size"); -#define MA_ARENA_NUM_BLOCKS (2048u / MA_BLOCK_SIZE) +static_assert(SHAPED_RUN_SLAB % MA_BLOCK_SIZE == 0, "slab must be a multiple of the block size"); +#define MA_ARENA_NUM_BLOCKS (SHAPED_RUN_SLAB / MA_BLOCK_SIZE) #include "arena.h" #define MA_NAME Val #define MA_BLOCK_SIZE SHAPED_RUN_MA_BLOCK_SIZE -#define MA_ARENA_NUM_BLOCKS (2048u / MA_BLOCK_SIZE) +#define MA_ARENA_NUM_BLOCKS (SHAPED_RUN_SLAB / MA_BLOCK_SIZE) #include "arena.h" #include "kitty-verstable.h"