XTaskQueue: every queue using a port hears of a task submitted to it #2747
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by F1reworks10 on 2026-11-25T19:34:40Z.
A 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
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T19:54:43Z.
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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:03:12Z.
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.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:07:35Z.
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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:26:08Z.
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
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:11:57Z.
Review: APPROVED
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).
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T13:32:16Z.
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
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:11:05Z.
Review: CHANGES_REQUESTED
The
Port::attachedWeak<Queue>fan-out avoids lock-ordering cycles (all mutexes are released before invoking callbacks),modules::xasync::tests pass (15/15), andrustfmt(on changed lines),clippy, andxtask policyare clean.Two behavioral issues in the new
deliver/tell_monitorsflow should be fixed before merge:Immediate tasks still run uncanceled if a monitor terminates the queue (
xasync.rs:265-270)tell_monitors(target)now runs beforetask.run(false)onMode::Immediate, a monitor callback that callsXTaskQueueTerminate(queue, ...)observes termination and returns, yetdeliverstill invokestask.run(false)on the stack-heldtask(since it was never inport.tasksorqueue.delayed). Checkingself.terminated.load(Ordering::Acquire)aftertell_monitors(passing it totask.run(...)) avoids running uncanceled work post-termination.Composite queues sharing one
PortforWORKandCOMPLETIONreceive two monitor calls per task (xasync.rs:217-222,:278-292)Queue::newpushes both(queue, WORK)and(queue, COMPLETION)into the sameport.attached, so a single submission fires any monitor registered on that composite queue twice. If the monitor synchronously dispatches (XTaskQueueDispatch(..., INFINITE)), the first invocation drains the single task and the second invocation stalls submission waiting on an empty queue.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.