XTaskQueue: every queue using a port hears of a task submitted to it #2749
No reviewers
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!2749
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2749"
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?
@F1reworks10 on GitHub · 2026-11-25 19:34 UTC · original
F1reworks10:xtaskqueue-monitors-of-shared-ports→main· +112 −10 · 1 files · 1 commits · openA task submitted to a port only reached the monitors of the queue it was submitted through. So a composite queue built from another queue's ports never woke that queue's monitor.
The GDK documents both halves of a common setup:
Put together on main, callbacks submitted through the composite queue sit in the port while the dispatcher sleeps.
In the public reference implementation (libHttpClient's
TaskQueue.cpp,TaskQueuePortImpl::NotifyItemQueued), every port context attached to a port hears of each item queued to it. Each queue that uses the port therefore calls its monitors, with its own handle and the port it uses.The reference also calls the monitors before an immediate port runs the item. On main they were called after it had already run.
Change (
crates/victory-hle/src/modules/xasync.rs)Tests
monitors_hear_of_tasks_submitted_through_a_composite_queue: fails on main, because the owner's monitor hears nothing.monitors_hear_of_an_immediate_task_before_it_runs: fails on main, because the monitor hears of the task after it ran.cargo test -p victory-hlepasses. Clippy is clean with and without--all-features. This PR merges cleanly together with #2616 and #2618, and all 18xasynctests pass on the combination.🤖 Generated with Claude Code
@cloph-dsp on GitHub · 2026-11-25 19:54 UTC · original
Independent local verification of this PR (claim
VERIFY-2749-XTASKQUEUE-PORT-NOTIFICATIONSon #1633).cargo --locked,CARGO_BUILD_JOBS=2. No GPU, no game data, no clippy/rustup.crates/victory-hle/src/modules/xasync.rs(tell_monitorsplus two synthetic tests).git diff --check origin/main..HEADclean;origin/mainis an ancestor of the PR head.cargo test --locked -p victory-hle --lib monitors_hear_of --quiet→ 2 passed, 0 failed.cargo test --locked -p victory-hle --lib --quiet→ 148 passed, 0 failed (plus 1 doctest passed).origin/maininxasync.rs.victory-gpu/src/object.rsandvictory-hle/src/modules/xmem.rs; non-blocking.No blocking findings. AI-assisted (Hy4 flash).
@fuzeofficlal on GitHub · 2026-11-25 20:03 UTC · original
Reviewed and verified
63c930daon Windows 11 againstmain(13f91ca).Code review
Queue::newprunes deadWeak<Queue>entries underport.attachedand records(Arc::downgrade(&queue), kind).Queue::tell_monitorsupgrades liveWeakreferences underport.attached, drops that lock, clones each queue's monitor callbacks underqueue.monitors, drops that lock, and invokes all callbacks outside every lock—so callbacks re-enteringregister_monitor/unregister_monitor/XTaskQueueCloseHandle/XTaskQueueTerminate/Submit/Dispatchcannot deadlock.deliverenqueues ontotarget.submit(task)(wakingready) beforetell_monitorsforManual/Serializedports, avoiding lost wakeups for aDispatchtriggered by the monitor; forImmediate, monitors run beforetask.run(false).Portas bothWORKandCOMPLETIONrecords both(derived, WORK)and(derived, COMPLETION), notifying each attached queue with its own handle and port kind. (Minor non-blocking note: deadWeaks inattachedare pruned on the nextQueue::newrather than insidetell_monitors, which is fine unless a single long-lived port churns many short-lived composite queues.)Verification (Windows 11,
rustc 1.98.1MSVC)cargo test -p victory-hle --lib --locked(3 consecutive full parallel runs): 3/3 passed (148 passed, 0 failed+crash_child1 passed, 0 failedeach run, including both new composite/immediate monitor tests).cargo clippy -p victory-hle --all-targets --locked(default and--all-features): 0 warnings;cargo xtask policy: 184 files ok.git merge-treeagainst13f91ca,#2616, and#2618.@kotekompotek on GitHub · 2026-11-25 20:07 UTC · original
Matches the reference behavior: every queue sharing a port hears of items queued to it, so a composite queue's submits wake the owner's monitor and its dispatcher no longer sleeps through library work. Weak refs on the attached list can't resurrect dead queues, and the retain on attach prunes closed ones. Ordering is right too - immediate ports run the task after monitors are told.
@Marvisak on GitHub · 2026-11-25 23:26 UTC · original
Automated triage for the maintainers. In
crates/victory-hle/src/modules/xasync.rs, eachPortnow keeps a weak list of the queues that use it.Queue::deliver/tell_monitorscall the monitors of every such queue, outside the locks, so a task submitted through a composite queue wakes the owning queue's monitor. An immediate port now notifies before it runs the task. Both behaviours follow the cited public reference (libHttpClientTaskQueue.cpp). I checked that the weak references create no cycle, that dead entries are pruned inQueue::new, and that callbacks run with no lock held. One minor point: a composite queue that uses the same port twice hears of a task once per use. CI:checkpassing. This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 04:11 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-hle --lib modules::xasync::: 15 passed, 0 failed (including newmonitors_hear_of_tasks_submitted_through_a_composite_queueandmonitors_hear_of_an_immediate_task_before_it_runs).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@futurepro62 on GitHub · 2026-11-26 13:32 UTC · original
NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, fuzeofficlal, since none of them names a GPU run. Tested exact head
63c930d(on its base13f91ca).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 775 passed, 0 failed, 9 ignored.monitors_hear_of_tasks_submitted_through_a_composite_queue,monitors_hear_of_an_immediate_task_before_it_runs.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.