fix(render3d): nothing allocated in the steady state - the Vulkan allocator reuses its records

gvk_mem_new made a one-slot []pointer per allocation, and turned the requirement's size and
alignment into strings to read them as ints; gvk_list_drop_last rebuilt the spare-record list to
drop its last entry; gvk_mem_id did the string round trip on every free. One slot is kept
(gvk_map_slot), int() truncates a long, the spare list pops. Every Text.to_int(string(x)) in
render3d is int(x) now.

Vk.heap_bytes() (vk_mac.ll: malloc_zone_statistics' size_in_use; 0 on Windows) and
examples/rendering/steady.ludic, in the suite: a buffer released and made again 5000 times and
600 whole frames gain 0 bytes each - the allocator before this, 1,120,000 over the 5000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 11:14:56 +03:00
parent 3915af34c2
commit 866037a0d7
9 changed files with 119 additions and 19 deletions

View file

@ -250,3 +250,17 @@ push:
store ptr %p, ptr @lvk_pool
ret void
}
; ---- the heap in use --------------------------------------------------------------------------
; malloc's live bytes across the default zones, for a test that proves a path allocates nothing in
; its steady state (render3d's examples/rendering/steady.ludic). malloc_statistics_t is four
; words: blocks_in_use (u32, padded), size_in_use, max_size_in_use, size_allocated.
declare void @malloc_zone_statistics(ptr, ptr)
define i64 @lvk_heap_bytes() {
entry:
%st = alloca [4 x i64], align 8
call void @malloc_zone_statistics(ptr null, ptr %st)
%p = getelementptr [4 x i64], ptr %st, i32 0, i32 1
%n = load i64, ptr %p
ret i64 %n
}