Repository navigation
Conversation
|
Holding review: upstream PR #4885 is not yet approved. This stacked PR will be re-evaluated once the upstream lands an approval label. |
Repair weak-memory completion notifications with the two confirmed upstream enkiTS atomic-ordering fixes while preserving the pinned scheduler algorithm and normal worker counts. Apply the backport atomically and idempotently during configuration, and isolate custom dependency revisions from the managed patch. Exercise patch failures, revision transitions, auto-worker completion, and the editor workloads that previously stalled. Use the pinned-archive transport while keeping custom references isolated. Apply and verify the backport without inheriting the surrounding checkout's Git routing. Exercise archive population and custom-reference transitions offline. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
01a7ef1 to
141e305
Compare
|
Rebased onto the rewritten parent: the stack below was replayed onto master after #4882 merged. Replaying this layer's two commits one by one conflicted in the enkiTS wrapper, because the first commit still carried the git-tag fetch that master's #4880 replaced with the SHA256-checked archive, while the second commit ( |
jakildev
left a comment
There was a problem hiding this comment.
Review — job: backport task completion ordering fixes
Verdict: approve
Stacked on #4885 (cross-author, now fleet:approved). Reviewing the child diff only — upstream is approved separately. Cleared the fleet:awaiting-upstream-review gate.
Big picture: the PR does what it says. It backports only the ten memory_order changes (six on m_RunningCount, two on m_WaitingForTaskCount, two on m_NumThreadsWaitingForTaskCompletion) to the pinned enkiTS v1.11 archive, and applies them through a configure-time wrapper that verifies the result and fails hard on a partial or conflicting tree. Worker counts, partitioning and blocking behavior are untouched.
What I checked:
- Head
141e305e7fetched and checked out detached;git rev-parse HEADmatchesheadRefOid. python3 -I scripts/tests/test_enkits_completion_patch.pyon that head: 7/7 pass on macOS.git apply --checkofcompletion_ordering.patchagainst a real v1.11 source tree already on disk (build-game-pool-7/_deps/enkits_src-src): bothsrc/TaskScheduler.cppandsrc/TaskScheduler.hcheck clean. This was a check only; nothing was mutated.- The patch hunks are exactly ten
-/+pairs, eachacquire|release->acq_rel, andtest_backport_contains_only_all_ten_atomic_order_changespins that. I did not diff against the upstream commits (845b837, d1752d0) since I have no network access here, so "matches upstream" rests on the author's claim. apply_completion_ordering.cmake: reverse-check first (idempotent no-op when already applied), forward check, atomic apply (no--reject), then a reverse-check verify. Git routing env vars are unset andGIT_CEILING_DIRECTORIESis pinned, so an archive tree inside the engine checkout can't patch the parent. Sound.isolate_completion_sources.cmake+ theFETCHCONTENT_BASE_DIRrestore afterFetchContent_MakeAvailable: customIR_ENKITS_GIT_REFrevisions get a per-hash base dir, so git's update/stash path can't carry the default patch across a switch. The default-only apply (if(NOT IR_ENKITS_GIT_REF)) matches the VERSION/CLAUDE.md wording that custom revisions own their own fixes.test/job/ir_job_test.cpp: a 2000-iteration auto-pool stress with asserted worker participation and write visibility after each join. The comment is honest that stress alone does not prove ordering.- Checks on the head: format-check, header-checks, instruction-size, no-plan-files, closes-lint, python-lint, whitespace, comment-refs, changes all SUCCESS.
linux-build,render-harness-testsandfleet-testswere still IN_PROGRESS when I read them, so those three are unread, not green.
Nits (follow-up)
scripts/tests/test_enkits_completion_patch.py(test_configure_revision_transitions_do_not_carry_default_patch): the opus-architect comment on this PR reports this one case fails on native Windows because the temp configure picks the Visual Studio generator and archive verification errors in populate. The innercmake -S/-Bcall could pin a generator (-G Ninja, or the inheritedCMAKE_GENERATORif set) so the suite is portable to the Windows host. It is not run by any check I can see on this head, so it does not block. I did not reproduce the Windows failure.engine/job/third_party/enkiTS/VERSION: the new preamble sits above theenkiTS v1.11identity line, so the file's first line no longer names the version. Consider appending the backport note below the existing lines.
Praise
- Verifying the patch on every configure (including already-populated and disconnected trees) with an atomic apply, plus negative-control tests for partial, conflicting and missing-source states, is a careful way to carry a vendored dependency patch.
Test plan the author should run before merge
- Linux/OpenGL:
fleet-build --target IRJobTest(or the repo's job test target) and runIRJobManagerTest.AutoPoolRepeatedShortChunksCompleteAndPublishWritesrepeatedly; the author's validation is macOS/Metal only, per the PR body.
Escalation: please Opus-recheck before merge (touches: engine/job scheduler atomic memory ordering, a concurrency change I cannot independently confirm beyond "the patch applies and matches the stated ten upstream edits").
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Opus recheck required: ten acq_rel memory-order changes in the enkiTS completion/wait handshake (concurrency); I confirmed the patch applies and is scoped to ten edits but did not independently verify the memory-model reasoning or diff against the upstream commits, and three CI checks (linux-build, render-harness-tests, fleet-tests) were still running.
jakildev
left a comment
There was a problem hiding this comment.
Opus recheck — job: backport task completion ordering fixes
Verdict: approve (with nits)
Stacked on #4885 (cross-author, fleet:approved). Reviewing the child diff only — upstream is approved separately.
Sonnet asked for two things it couldn't settle: whether the ten edits match upstream, and whether the memory-model reasoning holds. I checked both and they hold. The backport is exact and the ordering change is sound for every target we ship. Approving.
Upstream match (Sonnet left this unverified)
- I pulled 845b837 and d1752d0 through the GitHub API. 845b837 has four
WaitForTaskCompletionRMWs; d1752d0 has sixm_RunningCount.fetch_subs, five inTaskScheduler.cppand one inTaskScheduler.h. That makes ten, and all ten areacquire|release→acq_rel, the same ascompletion_ordering.patch. The one context difference is v1.11'sfetch_sub( numRun + 1, …), which upstream later renamedcountToRemove. The order change on that line is the same. - Upstream master today (
src/TaskScheduler.cpp) still hasm_NumThreadsWaitingForNewTasksatacquire/release, and still hasreleaseon the wake CAS and onm_DependenciesCompletedCount. So skipping those leaves nothing out compared with upstream. - Upstream also has a later dependency-teardown fix, 404a3bf, which reads
m_DependenciesCountbefore thefetch_add. It isn't needed here:engine/job/src/ir_job.cpponly usesAddTaskSetToPipe,AddPinnedTaskandWaitforTask, and never enkiTS dependencies.
Memory-model reasoning (Opus-only item)
-
Write visibility after a join: a real fix in the formal model. Before the patch, a non-final worker's
fetch_sub(release)was read by the final worker'sfetch_sub(release). Release alone does not acquire.TaskCompletethen doesstore(0, release), and a plain store does not continue a release sequence. So the main thread's acquire load of0inGetIsCompletesynchronized only with the final worker. The other workers' row writes were not formally visible. Withacq_rel, the final worker's RMW acquires every earlier decrement, and the releasestore(0)carries them to the waiter. That is what the newAutoPoolRepeatedShortChunksCompleteAndPublishWritesassertions check. -
Lost wakeup: sound in practice, not formally.
WaitForTaskCompletionincrementsm_WaitingForTaskCountand then loadsm_RunningCount. The completer decrementsm_RunningCountand then loadsm_WaitingForTaskCountinTaskComplete. That is a store-buffering shape. In the C++ abstract machine, only seq_cst rules out the outcome where both sides read the old value, andacq_relRMWs plus acquire loads do not.acq_reldoes two things here:- It stops the compiler moving the later acquire load above the RMW. With a release-only RMW that move was legal.
- It lowers to code that orders correctly on hardware:
LDADDAL/LDAXR…STLXRfollowed byLDARon ARMv8, whose release/acquire is RCsc, andlock xaddon x86.
So the fix holds on every target we ship, which matches upstream's choice and the author's caveat that stress is not proof. This is an observation, not a request. Moving off upstream's orders would be a fork, and the PR is right to stay narrow.
CMake mechanics
isolate_completion_sources.cmakeoverridesFETCHCONTENT_BASE_DIRas a normal variable insideengine/job/third_party/enkiTS, which is anadd_subdirectoryscope. It restores it right afterFetchContent_MakeAvailable, so nothing leaks to the parent and the cache entry is untouched.apply_completion_ordering.cmakeruns a reverse-check (a no-op if already applied), then a forward check, then an atomic apply, then a reverse verify.GIT_CEILING_DIRECTORIESplus unsettingGIT_DIR/GIT_WORK_TREEstops the normal in-worktreebuild/_depstree from resolving to the engine repo.
What I ran (macOS ARM64 / Metal, head 141e305e7, checked out detached)
fleet-build --target IrredenEngineTestagainst an existingbuild/, populated with v1.11 before this PR: exit 0. Re-configure patched the already-populated tree in place, andgrep -c acq_relinbuild/_deps/enkits_src-src/src/gives 9 inTaskScheduler.cppand 1 inTaskScheduler.h.fleet-run IrredenEngineTest --gtest_filter='IRJob*:*Job*' --gtest_repeat=10: all 33 tests passed on every repeat.IRJobManagerTest.AutoPoolRepeatedShortChunksCompleteAndPublishWriteswith--gtest_repeat=50and 10 workers: 50/50 OK, 0 FAILED.python3 -I scripts/tests/test_enkits_completion_patch.py: 7/7 OK.- CI:
render-harness-tests, which runs this Python suite on Linux throughrun_all.sh, andfleet-testshave both finished green since Sonnet's pass.linux-buildwas still pending, not green when I read it.
Nits (follow-up)
- I confirm Sonnet's nit on
test_configure_revision_transitions_do_not_carry_default_patch. opus-architect reports it fails on native Windows because the temporary configure picks the Visual Studio generator. The Linux CI copy passes. Pinning-G Ninja(or the inheritedCMAKE_GENERATOR) in the innerconfigure()would make the suite portable. This does not block. - I also confirm Sonnet's
VERSIONnit: the backport preamble now sits above theenkiTS v1.11identity line, so the first line no longer names the version.
🤖 Reviewed by Claude Opus 5.5 (opus-reviewer, review-pr recheck)
|
Addressed feedback:
|
|
New commits pushed after fleet approval. Re-tagging |
jakildev
left a comment
There was a problem hiding this comment.
Re-review — job: backport task completion ordering fixes
Verdict: approve
Delta-scoped re-review of head 54df55a32 (one new commit, test: stabilize enkiTS patch fixture, on top of the already Opus-rechecked 141e305e7). Stacked on #4885 (cross-author, approved); child diff only.
Both follow-up nits from the first two passes are addressed, and nothing else changed:
scripts/tests/test_enkits_completion_patch.py: the innercmakeconfigure now passes-GwithCMAKE_GENERATORfrom the environment, defaulting toNinja. That is the portability fix both reviews suggested for native Windows.engine/job/third_party/enkiTS/VERSION: theenkiTS v1.11identity block is back as the first line, and the completion-ordering backport note follows it. The text is only reordered. Nothing in the tree parses this file.
What I checked:
- Head fetched and checked out detached;
git rev-parse HEADmatchesheadRefOid(54df55a32b62d3e1489030bb261de75aed4a1869). git diff 141e305e7 54df55a32touches exactly those two files (12 insertions, 9 deletions). The patch, both cmake scripts and the C++ test are unchanged, so the earlier Opus memory-model review and its runs still apply to the executable surface.python3 -I scripts/tests/test_enkits_completion_patch.pyon the new head, macOS with Ninja present: 7/7 pass.- CI on this head: whitespace, python-lint, header-checks, comment-refs and closes-lint pass.
linux-build,render-harness-tests,format-check,instruction-size,no-plan-filesandchangeswere still pending when I read them, so those are unread, not green.
No new findings.
Opus recheck not required. The delta is a test-fixture argument and a docs reorder only, and the single Opus recheck for this PR already covered the executable change.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill, delta re-review)
Summary
Release editor profiling intermittently hung in transform propagation: the main thread waited for enki task completion while workers slept waiting for new work. The pinned scheduler lacks the atomic-ordering correction confirmed in upstream enkiTS issue 91.
Backport only the ten acquire-release ordering changes from upstream commits 845b837 and d1752d0. Worker counts, task partitioning, blocking waits and rendering behavior remain unchanged.
The default hash-checked archive and custom-ref transport match the dependency changes in #4880; its unrelated build changes are not included. The final archive-compatible Release editor is byte-identical to the measured executable.
The dependency wrapper verifies the actual patch on every configure and rejects partial/conflicting source state without partially applying it. Custom revisions use isolated FetchContent directories, preventing Git's update/stash machinery from carrying this backport into a different revision.
Test plan
Seven offline patch/archive/wrapper tests: fresh application, idempotence without timestamp changes, missing source, partial/conflicting failure, exact ten-operation scope, and default/custom/default transitions through incompatible, already-fixed and partially-fixed custom revisions.
Negative controls: missing hunk, no-op application, partial application and shared custom source directories each fail their intended tests. The final isolation mutation fails verification of the separate custom-source location.
Debug editor/test and Release editor builds pass with final dependency configuration.
Final 33 focused job tests × 20 repetitions: 660 passes, including 40,000 short auto-worker dispatches with asserted worker participation and verified writes after each join.
Both previously hanging editor scenarios pass three repetitions with default workers; no timeout or stack capture fires.
Fresh guarded editor matrix: all 24 × 360 frames pass, wrapper exit 0, quiet verdict GUARDED, qualification true; source/binary identity, frame count, pose, route and overflow checks pass.
Native lighting regression: all checks pass after the correction. Final Box/Line replay: 25/25 assertions, zero layout findings.
Measured editor cost
In the 219-cell Apple M4 Max/Metal fixture on AC power, accurate lighting adds an observed 0.156 ms and 0.108 ms to mean GPU envelopes at 30°/zoom 4 and 67°/zoom 8 with stage instrumentation off. Steady wall means increase 2.110/2.303 ms, but run-to-run variation is substantial and instrumentation changes one comparison's direction. This supports the editor-only quality default, not a stable FPS or universal 60 Hz claim. Raw paired measurements and the rejected pre-fix matrix remain separate.
Detailed evidence and limits
Validation is macOS ARM/Metal. Stress and application repetitions exercise the observed failure and data visibility after completion; they are not a proof that every possible scheduler race is absent. OpenGL/Windows/Linux runtime validation remains for other hosts.
Authored with Codex.
Overlap check
fleet-pr-overlapreports clean trial merges on all shared paths: