Repository navigation
mem-probe: the breakdown line says how much of each part is in host memory (RT-MEM-PROBE-HOST-SHARE) - #2767
mem-probe: the breakdown line says how much of each part is in host memory (RT-MEM-PROBE-HOST-SHARE)#2767kawaii-shakal wants to merge 3 commits into
Conversation
…emory (RT-MEM-PROBE-HOST-SHARE)
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
|
Verified by OreoFR on macOS 27.2.1, Apple M5, Apple clang (
AI-assisted: Claude Code |
|
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. 2. With the branch: 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 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 What that costs and what it teaches: What I did not test: the runtime path that feeds 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. |
|
Independent check on Windows (not the author), at
Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. AI-assisted: yes (opencode). |
KelboLive
left a comment
There was a problem hiding this comment.
The arithmetic is right: host bytes are a subset of bytes, not an addition (memory_breakdown.h:96-109), so total() and the allocated … = 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 prints 0 (0). The sample is recomputed from the live records, so nothing can go stale. Mutations behave: counting host bytes twice fails the total, and shrinking char item[256] to 48 fails the exact-text check.
The gap that matters: the rule lives only in mem_probe.h:550-552 and nothing tests it — memory_breakdown_test exercises Tally and format, but no test calls mem_probe::sample, so inverting the DEVICE_LOCAL test or dropping the flag would pass everything. A case with a synthetic DeviceFacts (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 with LEONIDA_MEM_PROBE set.
Minor, all read-the-line issues:
- The trailing
(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. - Parts and the host total are rounded independently to whole MiB, so the printed shares can be a MiB off the printed total (the parts already had this; now the host clause does too).
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.
…tested; the line says what its counts are (RT-MEM-PROBE-HOST-SHARE) Review follow-up (KelboLive): - Which memory type counts as host memory was decided inline in mem_probe::sample and nothing tested it. It is now memory_breakdown::in_host_memory(type, type_count, flags): a reported type without DEVICE_LOCAL. sample() calls it. The new host_types case pins it for a discrete GPU (VRAM, system memory, the BAR window), an integrated one and a type index the device does not report; it fails with the type bound dropped. - The format comment and runtime/README.md say that a number in parentheses is an allocation count, that each MiB figure is rounded on its own, and how long the longest items get against the 256-character buffer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
|
Thanks, all addressed in 5211e5c:
Linux (g++) and clang-cl + Wine (3/3) pass; merges cleanly into main aefb250. AI-assisted (Claude Code); I ran the tests and checked the results. Generated by Claude Code |
|
done: verified
So the rule moved to What I checked and what I did not: the build and the test binary on Windows/MSVC, so the 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. |
|
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 ( |
Item: 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 main f44904d.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