Skip to content

fix(job-manager): keep scheduling state in caller memory - #10231

Merged
oneandonlydean merged 26 commits into
boykopovar:mainfrom
Felipebmaitan:feat/jobmanager-owned-state
Oct 25, 2026
Merged

oneandonlydean merged 26 commits into
boykopovar:mainfrom
Felipebmaitan:feat/jobmanager-owned-state

Conversation

@Felipebmaitan

@Felipebmaitan Felipebmaitan commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What

JobManager now places its manager, factories, sequence objects, worker records, and bounded scheduling nodes in the work area returned by its size query. Intrusive queues and a 72-byte node pool replace heap containers. Waiting callers keep their temporary Wait record on their own stack, preserving the existing allocation-free node-exhaustion recovery. Destruction and failed initialization release native synchronization/thread resources without freeing caller memory.

Queued compute marker names are borrowed until their CPU barrier retires, matching the original module, just like shader-register inputs. The regression changes both inputs behind a held CPU job and proves that the queued dispatch reads the deferred values. There is no new claim that every dispatch is encoded at the API call: the original-module probe disproves that for a dispatch behind a CPU barrier.

This is a dependent PR for the next layer after #10166, #10188, #10202 and #10213. The independently reviewable topic commit is d14f5c0968c93c3e5654eb410456619c3e192683, parent aecb451d51; predecessor commits are included to make the exact combined head buildable. Base main snapshot: 4997726a5f. After the prerequisites land, rebase this branch to retain only this topic's diff. No prerequisite PR should be closed or superseded.

Integration order: #10202 → #10213 → #10231 → #10244 → #10254 → #10264 → #10272, followed by #10249 rebased on top. #10166, #10188 and #10706 have landed. This refreshed stack incorporates the #10706 public headers from main f26434afa3 and each refreshed prerequisite in that order. Preserve this landing order and the caller-owned, profiler, barrier, shutdown and Linux-reference changes. The focused runs below validate this composition; full-product CI and any further refresh after subsequent main changes remain separate.

Tested

Public-header/prerequisite refresh 8ab682946a on main f26434afa3, with refreshed parent 42bff60650. 28/28 distinct focused cases pass on each of Windows 11 / GCC 15.2 and Debian x86-64 / GCC 14.2: 27 CPU/lifecycle/failure-recovery/registration/progress cases, the compute fixture. Commands: ctest --test-dir <focused-build> -V (CPU), ctest --test-dir <focused-build> -R "^(agc_driver_job_manager_compute|guest_job_manager_profiler.*)$" -V (GPU/profiler), python core/libs/tests/test_public_headers.py --audit-only, python tools/check_conventions.py --base origin/main, and git diff --check. These pass. The current-main conventions checker, including its 8192-byte alignment rule, also passes. Public declarations/umbrella coverage are audited across all 368 libraries; affected headers and the reference adapter compile, and actual JobManager CMake targets/test registrations configure successfully with imported runtime dependencies. Each refreshed parent is an ancestor of its child.

Compute/GPU-profiler execution uses ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on RTX 5080 and llvmpipe. No capability skips, missing-layer warning or VUID- errors. The main f26434afa3 focused baseline passes 17 CPU cases plus the same compute fixture on the same platforms/devices, also with zero validation errors. The exact refreshed JobManager sources and fixtures use current public API headers with existing source-built runtime dependencies; GPU fixtures use internal headers matching those runtime binaries. These are focused author builds, not fresh full-product/current-main runtime builds or the full public-header compilation matrix. Full CI remains pending.

Earlier composition-specific evidence follows.

Stack refresh 376cab297d: merged main c8d34aa8f4 after #10166 landed. The landed scheduler/common regression code remains canonical; caller-owned queue operations and this PR's topic are retained. The refreshed parent is an ancestor of this head. 27/27 focused CPU/lifecycle/failure-recovery/registration/progress tests pass on each of Windows 11 / GCC 15.2 and Debian x86-64 / GCC 14.2, using the exact refreshed JobManager sources and fixtures with existing source-built runtime dependencies. Conventions, script registration and diff whitespace checks pass. Full product/current-runtime CPU/GPU CI remains pending the maintainer run; earlier GPU/reference results below belong to the stated earlier compositions.

Main refresh 9a7b9cc95b: merged main db6af9e0fd after #10188 landed, preserving this PR's topic and applicable scheduler repair. Reconciled the JobManager debt text into one set of nonduplicated bullets. Exact merged JobManager sources and CPU fixtures were rebuilt against the existing source-built runtime dependencies: 27/27 focused CPU/lifecycle/progress tests pass on Windows 11 / GCC 15.2 and Debian x86-64 / GCC 14.2. Conventions, script registration and PR diff whitespace checks pass. Full product/current-runtime CPU/GPU CI remains pending the maintainer run; earlier GPU/reference results below apply to their stated pre-refresh compositions.

  • Maintainer scheduler follow-up 4e1e36d257: adapted fix(libSceJobManager): honor worker spin and persistence policies #10166 fix dca749aaa0 to the caller-owned intrusive queues. The two-worker zero-spin/zero-persistence worker_wait fixture verifies the spare is parked, then requires a publisher to dispatch one child on a separate sequence and wait without any later external dispatch. Prior head d14f5c0 fails the bounded child-progress assertion on native Windows and Linux; the repaired combined head passes. Recompiled this PR library and fixtures against the existing source-built runtime dependencies: 27/27 focused CPU/lifecycle/registration/progress CTest cases plus the compute CTest pass on both Windows 11 / GCC 15.2 and Debian x86-64 / GCC 14.2. Compute used require-Vulkan/no-cache/validation on RTX 5080 (Windows) and llvmpipe (Linux), with zero VUID lines and no missing-layer warning. This is a focused composition rerun, not a new full-product build. Existing prerequisite order is retained.

  • Windows 11 Pro, MinGW GCC 15.2: the exact combined head passed 28/28, 14.75 s. Linux x86-64 Debian bookworm, GCC 14.2: 28/28, 13.70 s. Both use ctest --test-dir build -R '^(guest_job_manager_|guest_ulobjmgr|agc_driver_job_manager_compute)' -V. The Linux source snapshot was verified by SHA-256 against the checkout.

  • The ownership fixture covers 1 and 13 workers, 1 and 32 sequences, three reinitialization/recycling rounds, pointers into the supplied block and guard bytes after it. Compute storage tests check manager/factory/sequence placement for heap and mapped direct-memory areas. Concurrent Wait tests cover normal retirement and shutdown cancellation. Existing node exhaustion, worker policies, 45 initialization failure injections and registration tests remain passing.

  • Owned PPSA06888 module through ordinary Windows relinker startup: owned_state and concurrent_wait pass. The complete compute fixture passes against both the original and fallback, including direct-memory ownership, maximum register/marker capacity and deferred input reads. The previous integrated fallback fails the new borrowed-marker assertion as a negative control. No proprietary module or disassembly is included.

  • Focused main baseline 4997726a5f passed 9/9 on the same Windows machine and RTX 5080. Main and changed GPU runs use ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; all compared logs contain zero missing-layer warnings and zero VUID- lines. Linux change runs on Mesa llvmpipe with the same required-layer flags and also contain zero of either. No speed claim.

  • Eleven focused Linux cases pass UBSan with -fno-sanitize=vptr because the guest ABI fixture intentionally invokes compatible vtables through independently declared C++ interface types. ASan could not start: its shadow-memory reservation conflicts with the custom guest address arena and reports guest address space arena exhausted. This is not an ASan pass.

  • GPT-6.1-sol adversarial review found no blocker. Independent probes exercised eight simultaneous Wait callers through 20 recycling rounds and cross-sequence shutdown. The reviewed topic files are unchanged by the final main refresh.

  • python tools/check_conventions.py --base origin/main and git diff --check pass. The required overlap scan completed: the four declared predecessors are the JobManager overlaps. Conflicting test: organize library tests and label CTest suites #6044 was manually reviewed earlier and only relocates/registers tests. Other uncomparable shared files are docs/dev/ENVIRONMENT.md changes from the CPU prerequisite; this topic does not modify that file.

To reproduce the native ownership/concurrent-wait checks, build job_manager_reference and run python tools/run_job_manager_reference.py --module <owned-module> --build build --relinker <relinker.exe> --toolchain <compiler-bin> --cases owned_state concurrent_wait. The compute adapter published in #10188 runs the complete updated fixture from this checkout.

Original-module comparisons exercise the host services, not a PS5. Console timing and advancement in a real calling title remain unmeasured. GPU-active shutdown and native rewind command batching remain follow-ups.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(job-manager): cancel CPU work safely during shutdown #10202, fix(job-manager): forward object registration results #10213
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 621.01, Windows 11 Pro; Mesa llvmpipe 22.3.6 (LLVM 15.0.6), Debian bookworm, Linux x86-64
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Progress report (cf528e7 → 8ab6829)

➖ System libraries: 48.8% (+0.0%, +2 implemented functions)

✅ 2 implemented
Library Name
ulobjmgr _sceUlobjmgrRegisterObject_nid_postfix
ulobjmgr _sceUlobjmgrUnregisterObject_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
ulobjmgr 2/2 (100.00%) 4/4 (100.00%) +0.00 pp

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Exports introduced here that are already present in main:

  • _sceUlobjmgrRegisterObject
    _sceUlobjmgrUnregisterObject
    Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
Pull request Shared files not compared
PR 10249 core/libs/prx/libSceJobManager/Export.cpp
PR 10717 core/libs/tests/GuestJobManager.cpp

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Felipebmaitan This combined head carries the publish-then-wait progress hole: WakeWorkers at Export.cpp:346–349 subtracts the publishing worker, while WaitLocked at lines 651–670 blocks without helping or waking a spare worker. Please add a bounded two-worker regression with spin/persistence zero, the spare parked, and a callback that publishes one child job on another sequence and waits for it without later external dispatch. Ensure it progresses, or establish and enforce the original module’s restriction on this pattern, with native Linux/Windows failing-before/passing-after evidence. Preserve the prerequisite order and rerun the final composition after the scheduler fix.

@Felipebmaitan

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Addressed your combined-head progress request in 4e1e36d. This adapts the #10166 scheduler repair (dca749a) to this PR's caller-owned intrusive queues. The existing prerequisite order (CPU, compute storage, lifecycle, registration, owned state) is unchanged.

Added the same bounded two-worker worker_wait regression: spin and persistence zero, spare verified parked via its CPU clock, publisher dispatches one child on another sequence and waits, with no later external dispatch. Before the Export.cpp repair, exact head d14f5c0 fails its 3-second child-progress assertion on both native Windows and Linux. The repaired composition passes on both. Before a worker blocks, WaitLocked now wakes spare workers for runnable invocations without counting the blocked publisher as available.

Final composition rerun after the scheduler fix: 27/27 CPU/lifecycle/registration/compute-progress cases plus the compute CTest pass on each platform. This includes the existing spin/scale/wake controls, caller-memory ownership, shutdown, failure recovery and registration coverage. The compute runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on Windows RTX 5080 and Linux llvmpipe: zero VUID lines and no missing-layer warning. These focused builds recompile this PR's library and fixtures against existing source-built dependencies; no new full-product build is claimed. Conventions, test-script registration and diff whitespace checks pass.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Felipebmaitan #10166 is merged now (924b18f), so the scheduler layer underneath this stack is settled on main.

This PR and the ones stacked on it (#10244, #10254, #10264, #10272) now conflict with main in libSceJobManager/Export.cpp, libSceJobManager/CMakeLists.txt, tests/GuestJobManager.cpp, tools/run_job_manager_reference.py and the job-manager debt doc (#10272 also in tests/JobManagerReference.cpp). Most of that is expected: this branch carries its own copy of the blocked-publisher wake repair (4e1e36d) that #10166 landed with the std-container queue types, plus #10188's compute layout changes on main.

Could you merge main into #10231 first, keeping main's version of the parts #10166 already landed, and then refresh the stacked branches on top of it in order? I'll review each refresh and run full CI once they're up. #10213 conflicts only in the debt doc, so I'll handle that one on our side.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Felipebmaitan, this PR and the four stacked on it (#10244, #10254, #10264, #10272) now conflict with main. b7640ae5a3 (job-manager scheduler debt reconcile, merged 24 Oct 01:48Z) overlaps the same code:

  • seven hunks in libSceJobManager/Export.cpp;
  • two in tests/GuestJobManager.cpp;
  • the CMake registration, the debt doc and run_job_manager_reference.py.

We usually refresh simple conflicts ourselves, but these are real code merges across a five-PR stack, so you're better placed to resolve them once at the bottom. Could you merge current main into #10231 and carry it up through the stack? We'll run full CI on each new head.

@Felipebmaitan

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Addressed your bottom-up stack refresh request, including the earlier guidance to keep the landed scheduler parts canonical.

Merged current main c8d34aa8f4d8058d57169cc1e423ba6db00faaf0 into #10231 first, then merged each refreshed PR head into the next branch in the declared order. Each published parent below is an ancestor of the following head.

PR Refreshed head Merged parent
#10231 376cab297d c8d34aa8f4
#10244 b1efedd841 376cab297d
#10254 752165a81b b1efedd841
#10264 0ff4d3093d 752165a81b
#10272 2c8e9a0045 0ff4d3093d

The shared WakeWorkers, WorkerEntry, worker_wait, worker_spin and worker_wake implementations match landed main exactly. WaitLocked retains the same blocked-publisher wake behavior with the required intrusive-queue traversal and item.cpu fields for caller-owned storage. CMake keeps the landed registrations once, GuestJobManager keeps the common regressions once plus this stack's additional cases, and the lower reference runner starts from main with the owned-state/concurrent-wait case additions.

The later refreshes retain profiler registration/ID handling, GPU lookahead encoding/completion, compute-shutdown behavior, and the Linux reference adapter/parity selection. Debt text carries main's clock/reference limitations without reintroducing resolved host-heap, registration or profiler gaps. #10213 was left untouched for your side as requested.

Validation on every new head: 27/27 selected CPU/lifecycle/failure-recovery/registration/compute-progress CTest cases pass on each of native Windows 11 / GCC 15.2 and Debian x86-64 / GCC 14.2. This includes the blocked-publisher regression and existing spin/scale/wake controls. The refreshed sources and CPU fixtures were rebuilt against the existing source-built runtime dependencies. Local conventions, script registration, PR whitespace checks and JobManager CMake parsing pass.

All five published heads are currently mergeable with main. The latest hosted checks have no failures, with some relinker/conventions jobs still running. These focused author runs do not replace fresh full-product/current-runtime CPU/GPU CI; the five heads are ready for the review and full CI runs you offered.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Felipebmaitan thanks for refreshing the stack, and for the barrier-debt fix in #10254, which reads right now. Two things before the next refresh, which will follow #10706 anyway:

  1. fix(job-manager): keep scheduling state in caller memory #10231 sits on the old prerequisites. fix(job-manager): cancel CPU work safely during shutdown #10202 and fix(job-manager): forward object registration results #10213 were refreshed (c8cbf55, 2bed14c), but fix(job-manager): keep scheduling state in caller memory #10231 (376cab2) still carries the earlier copies of their commits. Merging the stack in order onto current main, fix(job-manager): cancel CPU work safely during shutdown #10202 and fix(job-manager): forward object registration results #10213 apply cleanly, and then fix(job-manager): keep scheduling state in caller memory #10231 conflicts in libSceJobManager/CMakeLists.txt, Export.cpp, core/libs/tests/GuestJobManager.cpp and the debt doc. Could you merge fix(job-manager): forward object registration results #10213's new head into fix(job-manager): keep scheduling state in caller memory #10231 and carry it up through test(job-manager): run original-module fixtures on Linux #10272?

  2. Collisions to expect from refactor(libs): add full export headers for libs #10706 (export headers), so the refresh keeps both sides' intent:

The other six heads pass review as they stand. We will run full CI on the stack after that refresh.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Felipebmaitan A correction to my note above, now that #10706 has merged with its public-header rule (each exported function declared exactly once, in the library's public header reachable from <library>.hpp, and no local declarations in .cpp files or tests; checked by the public_headers tests). For the refresh:

  1. Tests: every PR in the stack adds local export declarations in its tests (4 to 19 lines). Please drop them and include the umbrella header instead. One of them, getSequenceFactoryInterface, is declared returning void*, while main's Api.hpp returns ISequenceFactory*.
  2. Export.cpp: the job manager's local extern "C" block and the forward declaration of its own shutdown export should go too.
  3. From fix(job-manager): forward object registration results #10213 up: _sceUlobjmgrRegisterObject_nid_postfix and _sceUlobjmgrUnregisterObject_nid_postfix are not declared in any header. My earlier line said to keep them where they are; that's no longer allowed. Your call: declare them in ulobjmgr's public header, or call the existing exports instead.

The other declarations already match main's signatures. After the refresh, public_headers is part of the CI bar for every PR in the stack.

@Felipebmaitan

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Addressed both the prerequisite refresh and public-header correction.

Refreshed from landed #10706/main f26434afa3, carrying each new parent through the entire stack. Every parent below is an ancestor of its child. A sequential trial merge of all seven onto later main cf528e78c6 is also clean.

PR Published head Refreshed parent Distinct focused cases passing on each OS
#10202 43efd58266 f26434afa3 25
#10213 42bff60650 43efd58266 26
#10231 8ab682946a 42bff60650 28
#10244 043c7de79a 8ab682946a 30
#10254 55efb35489 043c7de79a 30
#10264 0d4025f98f 55efb35489 30
#10272 b31ed5dc5b 0d4025f98f 30

The reconciliation removes local export declarations/API type copies from the added fixtures and uses umbrella headers. JobManager's local import block and shutdown forward declaration are gone. The two _sceUlobjmgr*Object_nid_postfix aliases are declared exactly once in ulobjmgr's public Api.hpp, reachable through ulobjmgr.hpp, which JobManager includes. Registration behavior is retained. Factory fixtures and reference-adapter wrappers now use the canonical ISequenceFactory* return type. Attribute destruction stays solely in ThreadAttributes RAII; no duplicate post-create destruction remains.

test_public_headers.py --audit-only passes on every final head: 368 libraries, 12,171 exports at #10202 and 12,173 thereafter. Affected headers and all seven reference adapters compile; actual JobManager CMake targets/test registrations configure with imported runtime dependencies. Both branch and newer-main convention checks, including alignment, pass. I checked ancestry, whitespace, unchanged production runtime logic after accounting for moved API definitions, and byte-identical debt files against the prior published heads. The barrier-debt correction and layer-specific shutdown/reference differences are preserved.

GPU retest: both the previous #10254 head and the header-refreshed head reproduced Windows device loss/timeout in the old 134-million-iteration synthetic spin. Reducing that workload passed. I replaced the timing-dependent overlap setup with a separate GPU2 gate released by the CPU callback, plus a three-second rescue that explicitly fails the test if used. The callback must observe GPU1's output while GPU2 is blocked; GPU2 must finish before Wait returns. The new full fixture passes on both platforms and in three repeat rounds. A Windows negative control omitting the callback release fails the deadline assertion, cleans up, and has no device loss. Earlier failures remain recorded. This fixture-only repair is propagated through #10264/#10272; other compute/shutdown assertions are retained.

The table's CPU/compute/profiler cases pass on Windows 11 / GCC 15.2 and Debian x86-64 / GCC 14.2. Compute/GPU-profiler tests actually execute on RTX 5080 (621.01) and llvmpipe with require-Vulkan, no shader cache and Khronos validation: zero VUID or missing-layer errors. The main f26434afa3 baseline passes its 17 CPU cases plus compute on the same platforms/devices, also with zero validation errors.

Fresh #10272 reference runs on each OS pass 16/16 host-all, 14/14 host parity and 14/14 original-module parity. Host hash is null; original SHA-256 is 881a191e0c7509edc09b7360cfe470bc5692b2ef8ef2fadcbebe0ef23bdb933d. Provider, selections, exclusions and per-case results are recorded. The existing node_pool/worker_wait parity exclusions are unchanged; host-all includes both and has no exclusions.

All published heads/descriptions are verified and all seven are mergeable. No latest hosted check is failing; some relinker jobs remain pending. Descriptions include the refreshed order and concrete commands/results. These focused author builds use existing source-built runtime dependencies, current public API headers and matching internal GPU-runtime headers; they do not replace fresh full-product/current-main runtime CI or the entire public-header compilation matrix. Full CI remains the next validation step.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@oneandonlydean
oneandonlydean merged commit 096d770 into boykopovar:main Oct 25, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants