Repository navigation
Conversation
VMA allocates memory for large heaps in 256 MiB blocks by default. Freed allocations leave partly used blocks behind: in 007 on a 16 GB card the allocator held 4.2-4.7 GiB of block memory that no allocation used, and device-local usage stayed 1.9-2.3 GiB over the memory budget, with the excess placed in GTT. Use 64 MiB blocks for large heaps. VMA's heuristic now gives allocations above 32 MiB memory of their own.
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GraphicContext::CreateAllocatorcreates the VMA allocator with VMA's default block size. On heaps above 1 GiB VMA suballocates images and buffers from 256 MiB blocks, and its heuristic gives an allocation memory of its own when it is larger than half a block. VMA frees a block only when it is empty, so freed allocations leave partly used blocks behind.CreateAllocatorsetspreferredLargeHeapBlockSizeto 64 MiB. Heaps of 1 GiB or less keep VMA's own size (one eighth of the heap). VMA's heuristic now gives allocations above 32 MiB memory of their own.In 007 on a 16 GB card, in a series with diagnostic logging, this takes device-local usage from 1.9-2.3 GiB over the memory budget to 0.1-0.7 GiB under it. Without the logging the title's GTT use drops by about 2.1 GiB and the frame rate rises by 39 % (see Tested).
This treats the symptom. The unused block memory builds up as 007 frees and creates memory, not only in large images: in a diagnostic run with a switch that gave every image of 8 MiB or more memory of its own, 007 created about 7 such images per frame on average and 2.6 GiB of block memory was still unused. Reducing that churn is separate work.
Known limits:
maxMemoryAllocationCount= 4294967295; the Vulkan minimum is 4096.Tested
007 First Light (PPSA11386), Linux (CachyOS, kernel 7.3.4), Ryzen 9 7950X3D, AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.2.6). Release builds,
SDL_VIDEODRIVER=x11, scripted pad input, one save and route, shader caches warmed from one earlier run, the local 5-byte title patch and the setup described in #98.This PR is based on
7de61e3451. All title runs used7de61e3451+ #278 + the code of #289, the stack of the #98 runs. This PR changes no file that #278 or #289 change. It was not measured on7de61e3451alone.Diagnosis: a diagnostic build (the stack above plus logging, not part of this PR; logging on, its diagnostic switches unset) wrote a VRAM breakdown every 60 frames. 6 runs with the default block size, 20 dumps each, median of the per-run medians:
The block size as a switch (an environment variable, not part of this PR), both arms in the same binary, 300 s per run. FPS is the median of the window-title FPS over 200-300 s.
amd-evicted-vram0).Flip telemetry, one more pair on the build with the switch: the default, then 64 MiB,
APS5_VIDEOOUT_FLIP_TIMING=9000:2000in both runs, the same revision twice as ANYKYTY.md describes for two settings of one build (7af6efb7b9is that local test build). Mean FPS here is over the completed flips of the window, not the window-title median above.tools/videoout_flip_compare.py default/videoout.jsonl 64mib/videoout.jsonl --baseline-revision 7af6efb7b9... --candidate-revision 7af6efb7b9...:7af6efb7b99fb679615db08b6b1fa4dfbd01eadd7af6efb7b99fb679615db08b6b1fa4dfbd01eaddagc_kyty_shaders,guest_gpu_fault,guest_host_write_filter) gives the same result per test on7de61e3451and on this PR: 107 passed,kyty_shim_rt_corpusskipped,kyty_shim_wave64_cross_laneandkyty_shim_wave_split_written_readsfail here on both. No test is added: the change is one allocator parameter.kyty_shim_image_write_back_aliasalso passes withVK_LAYER_KHRONOS_validation1.4.363,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1(the layer loaded, per the loader log; no validation messages).tools/check_conventions.py --base 7de61e3451andtools/check_kyty_settings.pypass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code