fix(vk): count and log only the guest-memory imports that reached the driver #2165
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2165
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/import-log-reached-driver"
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?
Summary
When the driver refuses to import a range of guest memory, the log claims huge numbers of imports that never happened,
and the refusal itself drops out of the log. #859's AMD Windows log shows this: after about 1.15 GB was imported, the
driver answered
VK_ERROR_INVALID_EXTERNAL_HANDLE, and from then on the log showed about 1.25 million "imports" at0.0 ms each.
The cause is in
pool_lookupingpu/vk/vk_memory.cpp. It callsimport_poolup to twice per lookup, counts everycall as an import (
n++), and logs "imported in" on every 256th call, whether the import worked or not. After afailure,
ImportHoldsholds the range forkGapMs(2 s,gpu/vk/import_hold.h). While it is held,import_poolreturns false at once without calling the driver, and
import_coolinghides the "not imported" line. So every lookup ofa held range counted as an import that took 0.0 ms. To see it on
main, runtests/test_import_log.py: its driver stubrefuses one range, and it then counts 1000 lookups of that range, logged as "(256 imports, 0 ms in all)" and so on.
This PR changes only the counters and the log lines. Nothing about when an import is tried changes. Each attempt is now
counted by how it ended:
refused or held, the line reads exactly as on
main. Otherwise it adds; R refused, H lookups held.import_poolasked the driver and failed. The line is "not imported as lo..hi in X ms (VkResult V;R refused)", capped at 16 lines as before. Every refusal is counted, including those past the cap.
import_poolnowalso keeps the
VkResultof a refused host-pointer properties query or buffer create; before, it kept only a refusedallocate or bind.
kGapMsago, so the driver was not asked. These are counted apart. A line islogged for the 1st and every 65536th: "... not tried again yet (H lookups waited on a held range)".
At close (
mkwvk_close_asked), a new line gives all three counts: "vk: imports at close: N made, R refused by thedriver, H lookups waited on a held range".
Read first:
pool_lookup's import loop andimport_stats_logingpu/vk/vk_memory.cpp, andtests/test_import_log.py.No script under
scripts/ortests/reads these lines (searched for "imported in", "imports,", "not imported", "ms inall").
tests/import_reach_test.cppcompilespool_lookupwhole, so it now declares the three counters and includesimport_hold.h.See #859, #1443
Testing
Tested: Linux, RTX 3090, NVIDIA 620.70.06, this PR @
d9a1e62fas a pack, through the job queue: a memory tour fromkokiri-startthrough Zora's Domain, Hyrule Field, Kakariko, the Market and Kokiri Forest, 30 s each, in play, clean quit, no crash. The "imported in ... (N imports, M ms in all)" lines look as on main, with no "refused"/"held" suffix and no "not imported" line, and the close line readsvk: imports at close: 331 made, 0 refused by the driver, 0 lookups waited on a held range. The game-free testtests/test_import_log.pyis new. It cutspool_lookup's import passes,import_on_hold,import_remember_failureandimport_stats_logout of the source and runs them over a driver stubthat refuses. It fails on
mainfor the reason: the refusal is not counted, and the held lookups are logged asimports. It was written without being run on the author's PC (no test suites run there), so CI on the forge runs it,
along with
tests/test_import_reach.pyandtests/test_import_buffer_binding.py, which compile the changed functions.Still to test:
(VkResult -1000072003 ...)" lines and no run of 0.0 ms "imported in" lines; the close line gives the refused and held
counts (
@Beanstalk Windows AMD: a long memtour, then report the "not imported" lines and the "vk: imports at close" line).Measurements
Verdict: A logging fix: the counts are now correct. Nothing about speed changes, because no driver call or
decision about when to import changed.
8aa74983d9a1e62ftests/test_import_log.pyRisks
The log format changes only after a refusal or a hold: the "imported in" line gains a suffix, and the "not imported"
line gains the attempted range, its time and the refused count. No script parses either line. Behaviour is unchanged
and so is the per-lookup work: one atomic increment per attempt, under the lock
pool_lookupalready holds. A revert isenough to undo it. Players notice nothing.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (not run on this PC; CI runs it)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (written as test commit then fix commit; the result onmainand here comes from CI, not run locally)tests/that reads changed source is updated, not weakened. (tests/import_reach_test.cppdeclares the new counters)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Linux, RTX 3090, NVIDIA 620.70.06, through the job queue: memory tour of 5 areas from kokiri-start, in play, clean quit; import lines as on main with no refused/held suffix; close line: 331 made, 0 refused, 0 held. The refusal path needs AMD Windows (Test Farm).
@Beanstalk Windows AMD (where the driver refuses host-pointer imports, #859's setup), 16 GB RAM if available: a long memory tour from kokiri-start through several areas, then report the 'not imported' lines and the 'vk: imports at close' line; expect no run of 0.0 ms 'imported in' lines. Also Windows NVIDIA: a normal tour, expecting the close line with 0 refused, 0 held.
Beanstalk test farm · 🔄 testing (0 of 2 reports so far)
Commit
d9a1e62· approved by HumanBean (reviewed) · dashboard⚠️ Note: The 16 GB AMD target waits if no matching Windows AMD PC is available; online RAM and GPU counts do not establish that combination.
⚠️ Note: The shared plan cannot enforce zero refused and held only on NVIDIA, or distinguish a consecutive run of 0.0 ms import lines from isolated legitimate lines; it reports those counts for interpretation.
⚠️ Note: A refusal may not occur during this tour, and the new close summary is absent on main; refusal-path correctness then remains unjudged.
Done (started 2026-11-21 23:48 UTC). Comment
@Beanstalkto run it again.windows+amd+ram16gb(16 GB RAM)windows+nvidiaWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)On Windows AMD with 16 GB RAM and Windows NVIDIA, tour five areas from the Kokiri checkpoint and compare main with the pull request. The roughly 25-minute run records refusal and close-line counts, and fails for a crash or a missing close summary. Whether the AMD driver refuses imports is not guaranteed; the reported counts and logs show which path was reached. No tester online now matches windows+amd+ram16gb: that target waits for one.
kokiri-start, then teleport to Zora's Domain, teleport to Hyrule Field, teleport to Kakariko Village, teleport to Market, teleport to Kokiri Forest; 2 runs on each side.WIP: fix(vk): count and log only the guest-memory imports that reached the driverto fix(vk): count and log only the guest-memory imports that reached the driver