mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1291] [CLOSED] runtime: opt-in memory counters for the Vulkan device (RT-MEMORY-PROBE) #1322
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1322
Loading…
Reference in a new issue
No description provided.
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1291
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/rt-memory-probe📝 Commits (1)
4aa1096runtime: opt-in memory counters for the Vulkan device (RT-MEMORY-PROBE)📊 Changes
4 files changed (+311 additions, -21 deletions)
View changed files
📝
runtime/CMakeLists.txt(+12 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+5 -3)📝
runtime/src/mem_probe.h(+45 -18)➕
runtime/test/mem_probe_test.cpp(+249 -0)📄 Description
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.