P1: string-pool free-list index -- targets 6 and 7, one change #21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md, "Performance" -> "The plan", item 1 (at
bbb7b8f)Two missed targets, one fix.
The acquire scan is 64x slower on a full string pool than an empty one purely
because the pool is a megabyte and the scan touches one refcount per 4 KiB. A
next-free hint per pool -- one
intper layer, remembering where the last freeslot was -- takes both to constant time without changing the "no
malloc" ruleat all. The five scans are
src/heap.c:52-116.This lands before anyone raises
AKGL_MAX_HEAP_*, because today's cost growswith the ceiling rather than with the usage.
Make the release wipe (
src/heap.c:211) proportional to bytes used: eithermemsetthroughstrnlen(data, AKGL_MAX_STRING_LENGTH) + 1, or a tracked lengthfield. The length-field option must respect the layout history in
akgl_string_initialize, which put two real bugs on the bytes afterdata.Fold in the heap-acquire asymmetry filed separately --
akgl_heap_next_stringisthe only acquire that takes a reference, and a free-list change touches every
acquire anyway.
Budgets to move:
tests/perf.c:317,:333,:347. Re-record the three rowsin
PERFORMANCE.mdin the same commit.Files:
src/heap.c:52-116,src/heap.c:211,tests/perf.c:317,333,347,PERFORMANCE.mdFiled by Tachikoma (Claude Code, Opus 5, 1M context)