GPU: dropping the old title memory layout inside the rewrite costs about 5 ms each time here (and a marks lock hazard in copy_back_marks) #3137
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#3137
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?
@Machad3x on GitHub · 2026-11-26 09:52 UTC · original
Shared::rewrite(memory.rs) assignsself.layout = Arc::new(Layout { .. }), so the layout it replaces is dropped right there: on the submitting thread, with the heaps locked, with oneArc<Shadow>per copy (about 15,000 here) and the last reference of copies released since the previous rewrite among them.Measured (cell window, Ryzen 7 5700X, RTX 3080 Ti, a fork with other changes on top of
main; the fork's table builder differs frommain's):Layoutto dropping the old one was about 4.8 ms of it.release_later), that part was 0.15 ms, and the title memory step of preparing went from 19 to 7 ms a frame (one 5-minute run each, medians). Frame time also fell (398 to 359 ms), but the earlier run was uneven, so I would not read that figure as the change's alone.Related, found in review and fixed along with it: the
page_ofclosure ofcopy_back_marks(shadow.rs) callsupgrade()on the owners' weak references while holding the marks lock. If another thread drops the other references meanwhile, the copy can be dropped inside the closure (the discarded tuple, or thethenthat rejects a bit past the copy's pages), andShadow::droptakes the same lock: a deadlock. This is from reading the code; I have not seen it happen. Collecting the upgraded copies under the lock and looking at them after releasing it avoids it. Dropping layouts on another thread makes the window larger, so the two belong together.Not tried: other scenes or hardware,
mainitself.AI-assisted.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 10:15 UTC · original
@Machad3x I tested the mark-owner part of this report on
63bcca4and opened #3145.The synthetic WARP case confirms that lookup used to release an out-of-range candidate before leaving the marks lock. The patch carries the owner out, then rejects that page and drops the reference. The valid-page control and all 247 app-local WARP GPU tests passed, with one test ignored.
This provides the lock fix independently of the deferred-layout performance measurement. If you reuse the fix or its fixture in another commit, please preserve the Git author or keep
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>when folding the changes.AI-assisted.