mem-probe: the breakdown line says how much of each part is in host memory (RT-MEM-PROBE-HOST-SHARE) #2767
Closed
github-bot
wants to merge 3 commits from
github-bot/gh-2767 into main
AGit
pull from: github-bot/gh-2767
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2767
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2767"
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?
@kawaii-shakal on GitHub · 2026-11-30 17:12 UTC · original
kawaii-shakal:mem-probe-host-share→main· +99 −9 · 4 files · 3 commits · closed without mergingItem: RT-MEM-PROBE-HOST-SHARE (claimed in #2570). Part of step 1 (accounting) of #1702.
The
[rt] mem-probe breakdownline splits the runtime'svkAllocateMemorybytes by consumer, but where they landed is only on themem-probe t=line, summed over all consumers per memory type. A sampled texture that did not fit in the card's memory, the page mirror's homes once the budget is near, or the arena on a type without DEVICE_LOCAL (#1732) all look like memory on the card in the breakdown. Now each part adds its share in memory types outside the device-local heaps, which the GPU reads over the bus, and the total follows the parts:Tally::addtakeshost(default false, so other callers are unchanged);mem_probe::samplepasses it from the memory type's flags. Imported memory stays apart, as before.allocated N MiB = arena ...) is unchanged.runtime/README.md: theLEONIDA_MEM_PROBErow says so.Tests (Linux, CPU only, no GPU or game files):
runtime/test/memory_breakdown_test.cpp: newhost_sharecase (per-consumer host bytes and counts, imported memory left out, an out-of-range consumer counted as other, the text) and the total intext(). Passes natively (g++ 13,-Wall -Wextra, no warnings) and as a clang-cl 21 + xwin build with/W4 /permissive-under Wine (3/3); fails with the host part no longer counted inTally::add.src/mem_probe.htype-checks with clang-cl/Zs(0 errors, 0 warnings, as on main). Not built with MSVC here, and not run withLEONIDA_MEM_PROBEon a GPU.check_no_game_data.pyon the four files andgit diff --checkare clean. Merges cleanly into mainf44904d2.Heads-up: #2547 and #2549 (Tyrannys) also change
memory_breakdown.hand its test, in other hunks (DeviceShare/format additions); both need a rebase on main already, and whichever lands second has a small textual merge.AI-assisted (Claude Code): the change and the tests were written with it; I reviewed them and ran the tests.
🤖 Generated with Claude Code
The breakdown splits the runtime's allocations by consumer but not by where they landed; the memory types are only on the mem-probe t= line, summed over every consumer. A texture that did not fit in the card's memory, or the arena on a type without DEVICE_LOCAL, was not told apart from one in the card's memory. Each part now adds its share in memory types outside the device-local heaps ("sampled textures 2300 (412; 870 in host memory)"), and "in host memory" sums them after the parts. Imported memory stays apart, as before. Diagnostic only: nothing changes what is allocated or where. memory_breakdown_test: a new host_share case and the total in text(); it passes natively (g++) and as a clang-cl build under Wine, and fails with the host part no longer counted. mem_probe.h type-checks with clang-cl /Zs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3@OreoFR on GitHub · 2026-11-30 17:20 UTC · original
Verified by OreoFR on macOS 27.2.1, Apple M5, Apple clang (
-std=c++20 -Wall -Wextra -fsanitize=address,undefined),mainad25611b5, head092834570.main+ this PR, merged;runtime/test/memory_breakdown_test.cppbuilt alone againstruntime/src):memory_breakdown: ok, exit 0, no sanitizer report, no warning. The breakdown line now prints each part's host-memory share, e.g.arena 4095 (1; 4095 in host memory)andin host memory 4997 MiB (4).main's headers + this PR's test): does not build (no member named 'host_total' in 'leonida::memory_breakdown::Tally'; the calls with a 4th argument). So no red failure can be shown: the test needs the new API.mem_probe.hcall sites on Windows (CI), and the line in a real run.AI-assisted: Claude Code
@fiestorra on GitHub · 2026-11-30 17:34 UTC · original
Independent verification on this machine (Windows 11, RTX 4090, MSVC 19.44.35226), with a control - and with the first version of that control, which lied to me.
1. It applies and builds.
merge-treeclean ontomainbe7690805; the change isruntime/src/memory_breakdown.h(+30/-5),runtime/src/mem_probe.h(+3/-1), its test (+33/-2), and one line ofruntime/README.md.2. With the branch:
ctest -R '^memory_breakdown'-> 100% tests passed, 0 failed out of 1.3. The control is at the compiler, not at the assertion. Revert only the two headers, keep the test, build:
So the new test cannot exist without the change: it calls
Tally::host_total(),add(..., host)and asserts the rendered line contains900 in host memory, none of whichmainhas. That is a compile-level control, and it is the honest classification - the behavioural half ("the line says how much of each part is in host memory") is asserted by the test, but I did not run the new binary against the old headers, because it cannot be built there.The mistake worth recording, because it produced a false result in my own hands: the first time I ran that control, I piped the build to
Out-Nullwithout checking$LASTEXITCODE, then ranctest— and it reported100% tests passed. The build had failed andctestran the previous binary, the one built with the branch's headers. For a minute I had a "control that does not bite" in front of me, and it was my script, not the pull request.What that costs and what it teaches:
ctestafter a failed build is a measurement of the last successful build, and it will pass happily. Every control I have published today says "revert, rebuild, run"; this one is the first where the rebuild failing is the answer, and checking the exit status is what distinguishes "the test is insensitive" from "the test could not be built".What I did not test: the runtime path that feeds
Tallywith the host-memory flag (a texture that did not fit in VRAM, the arena on a non-DEVICE_LOCALtype). The test drives the type directly; whethermem_probepasseshostcorrectly on a real card is not covered by this control.AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent. Measured on Windows 11, MSVC 19.44.35226, RelWithDebInfo, no GPU needed for this test.
Written with an AI assistant.
@KelboLive on GitHub · 2026-11-30 18:19 UTC · original
Independent check on Windows (not the author), at
092834570.memory_breakdown_testand ran it:memory_breakdown: ok(exit 0).arena 4095 (1; 4095 in host memory)andin host memory 4997 MiB (4), alongside the existing device-side breakdown.Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.
AI-assisted: yes (opencode).
@KelboLive on GitHub · 2026-12-01 05:50 UTC · original · reviewed
The arithmetic is right: host bytes are a subset of
bytes, not an addition (memory_breakdown.h:96-109), sototal()and theallocated … =start are unchanged and the parts still sum. The test's line is 7077 = 4095 + 1800 + 1180 + 2 MiB, with 4997 host = 4095 + 900 + 2; imported memory is excluded from both; a part with no host memory prints exactly as before; and a zero-byte part prints0 (0). The sample is recomputed from the live records, so nothing can go stale. Mutations behave: counting host bytes twice fails the total, and shrinkingchar item[256]to 48 fails the exact-text check.The gap that matters: the rule lives only in
mem_probe.h:550-552and nothing tests it —memory_breakdown_testexercisesTallyandformat, but no test callsmem_probe::sample, so inverting theDEVICE_LOCALtest or dropping the flag would pass everything. A case with a syntheticDeviceFacts(one device-local memory type, one not) and two recorded allocations would pin it without a GPU; otherwise the feature is only verified by a run withLEONIDA_MEM_PROBEset.Minor, all read-the-line issues:
(4)is the host allocation count while a part's(N)is that part's own count — the README example reads like "4 memory types"; say what it counts.char item[256]truncates silently if a consumer name grows; asserting thesnprintfreturn would make that visible (the exact-text checks catch it only because they exist).Diagnostics only, nothing else touched, and the README row matches the text.
@kawaii-shakal on GitHub · 2026-12-01 06:42 UTC · original
Thanks, all addressed in
5211e5c5:mem_probe::sample: it ismemory_breakdown::in_host_memory(type, type_count, flags)(a reported type without DEVICE_LOCAL), whichsample()calls. The newhost_typescase pins it without a GPU: a discrete GPU's VRAM, system memory and BAR window (device-local, so not host), an integrated GPU (all device-local), and a type index the device does not report (not counted). It fails with the type bound dropped. The one line insample()that passes the allocation's type to it is still only type-checked (clang-cl/Zs), not run.LEONIDA_MEM_PROBErow inruntime/README.mdnow say that a number in parentheses is an allocation count (in host memory 4997 MiB (4)is 4 allocations), as it already was for every other part of the line.item[256]: the longest items (the arena's bracket, the closing note) stay near 200 characters even with ten-digit figures, so nothing is cut today; the comment says so.Linux (g++) and clang-cl + Wine (3/3) pass; merges cleanly into main
aefb2508.AI-assisted (Claude Code); I ran the tests and checked the results.
Generated by Claude Code
@fiestorra on GitHub · 2026-12-01 08:31 UTC · original
done: verified
5211e5c5on today'smain- it applies cleanly, builds, and the test passes.maincd73ddab7, the branch's commits cherry-picked (merge-base8f41d7d01, no conflict):So the rule moved to
memory_breakdown::in_host_memorydoes the same job in the same place:7077 MiBsplits into4095 (1; 4095 in host memory)and the rest, which is what the line was for. And theitem[256]case does not wrap even with ten-digit figures, judged by the two rows above.What I checked and what I did not: the build and the test binary on Windows/MSVC, so the
g++andclang-cl + Winearms kawaii-shakal ran are not repeated here - the point of that matrix is that somebody ran them on other toolchains, and they did. What I add is that it still merges into themainof this hour, which is not theaefb2508they merged into.Nothing else to change from me: the two commits are the feature and the fix, and the review's four points are all visible in the diff.
AI-assisted: yes - DeepSeek v4.1 (flash), a build and a run on the merged tree.
Written with an AI assistant.
@aslan2142 on GitHub · 2026-12-01 16:46 UTC · original
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.Pull request closed