Repository navigation
Conversation
This was referenced Nov 24, 2026
3 of 4 tasks
A long boot can run out of memory, and nothing says whether it went to Vulkan allocations, pipelines, the GPU address arena or the process itself. LEONIDA_MEM_PROBE=<seconds> wraps nine entries of the device's function table and writes, every <seconds> and once more when the device is destroyed, the live pipelines by kind, the shader modules and their SPIR-V bytes, VkDeviceMemory per memory type (allocated and imported apart), the arena's use, and the working set and private bytes of the process. Under Wine on Linux it also sums the process's smaps per kind of mapping. The lines hold counts, sizes and file names. Unset, nothing is wrapped, no thread is started and nothing is written. The sampling thread ends with the device. Cross-built gta6rt and mem_probe_test. The test drives a stand-in function table: unset, the table is untouched and nothing is written; set, the entries are wrapped, all calls still reach the driver and the lines carry the expected counts. Both forms passed under Wine 11.22. d3d12_draw_test passed with the variable unset and set on an RTX 4070. AI-assisted (Claude Code). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Moriz82
force-pushed
the
split/rt-memory-probe
branch
from
November 25, 2026 03:51
e3d997f to
4aa1096
Compare
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.
Claimed in the coordination issue as: RT-MEMORY-PROBE (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 (integration source; there the probe also read title memory ranges, descriptor shadow counts and the pipeline cache size, which need code main does not have and are left out). #1104 answers the title's
GlobalMemoryStatusEx. #576 dumps thread stacks. Neither counts where the runtime's memory goes.What and why
A long boot can exhaust memory, and the log does not say whether it went to Vulkan allocations, to pipelines and shader modules, to the GPU address arena or to the process outside Vulkan.
LEONIDA_MEM_PROBE=<seconds>turns on a probe in the Vulkan device (runtime/src/mem_probe.h). Every<seconds>, and once more when the device is destroyed, it writes to stderr:[rt] mem-probe t=...: live graphics and compute pipelines and how many were made, live shader modules and their SPIR-V bytes,VkDeviceMemoryper memory type with allocated and imported apart, and the arena's size, use by kind and peak end.[rt] mem-probe process: the working set and private bytes Windows counts for the process.[rt] mem-probe smaps, under Wine on Linux only:/proc/<pid>/smapsof the process summed per kind of mapping (PE private memory, PE images, PE sections, memory the driver mapped forvkMapMemory, device mappings, other native anonymous memory, native files), with the names of the four largest mapped files.The lines hold counts, sizes and file names. No line holds memory or file contents.
The Vulkan counts come from wrapping nine entries of the device's function table (allocate, free, map, unmap, shader module create and destroy, the two pipeline creates, pipeline destroy) before the device allocates anything. Only the first device of a process is wrapped. The sampling thread belongs to that device and is joined before the device's state is released.
With the variable unset, empty or
0, no entry is wrapped, no thread is started and nothing is written.A line from the run below, on a real device at teardown:
Tested
Cross-built on CachyOS Linux 7.3 with clang-cl 23.1.5 and the xwin SDK. Ran the Windows tests one at a time under Wine 11.22 (distribution build, fresh prefix) on a Ryzen 5 5600X, 16 GB RAM, NVIDIA GeForce RTX 4070 12 GB, driver 620.73.04.
mem_probe_testneeds no GPU. It gives the probe a stand-in function table and makes the same 11 calls in both forms: three allocations of which one is imported, one map, one free, two shader modules of which one is destroyed, three graphics pipelines and one compute pipeline, one pipeline destroyed.mem_probe_test(variable unset)mem_probe_test --ond3d12_draw_testLEONIDA_MEM_PROBE=1d3d12_draw_testpython3 -I scripts/check_no_game_data.py,tests/test_docs_env_vars.py,git diff --checkpython3 -I scripts/run_semantic_tests.py tests/semantic -j 2tests/test_imhex_patterns.py, as on the base. None added. Semantic suite: 470 files, 6,168 tests, 0 failing files.The base has no
LEONIDA_MEM_PROBE, so there is no base run of the new test: the evidence for the switch is the two forms above and the twod3d12_draw_testruns.Not run: native Windows (there the smaps line is absent and the process line comes from Windows itself), Proton, AMD and Intel GPUs, a timed sample on a real device (the device tests here end within a second, so only the sample at teardown was seen), CTest itself, and a boot of the title.
GPUs tested: NVIDIA GeForce RTX 4070, driver 620.73.04, Linux under Wine 11.22 (
d3d12_draw_testonly;mem_probe_testuses no GPU).AI-assisted: yes (Claude Code).
Checklist
🤖 Generated with Claude Code