Resolve copy-back block owners once per landing job #3275

Open
FifthImpact wants to merge 1 commit from upstream-pr/3275 into main
FifthImpact commented 2026-12-03 01:41:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by FifthImpact on 2026-12-03T01:41:40Z.


Claimed in the coordination issue as D3D12-LAND-BLOCK-OWNER-LOOKUP (claim).

What and why

When GPU writes land through a second view of game memory, each journal block needs the identity of the one buffer that can take credit for writing it. The previous implementation searched every piece of the job for each block. Index the existing vector once. The normal ordered, distinct case pairs corresponding entries directly. Incomplete or conflicting pieces still preclude credit, and repeated journal notifications keep their original order. The Windows and Wine paths use the same code.

Tested

  • Compared the old and new owner loops in an optimized Rust harness on Windows, alternating implementations on identical synthetic inputs. For ordered jobs of 4, 16, 64 and 256 distinct blocks, medians in ns/job were 25→23, 220→48, 2,999→161 and 37,168→649. One block was 7.7→8.3 ns. Four shuffled blocks were 27→31 ns. These measure the lookup only. No in-game FPS result.
  • The new regression case exercises repeated, unknown and conflicting owners, nonconsecutive arrivals and reverse order. On base the new test failed to compile because the indexing helper was absent. The performance comparison above uses the working base implementation.
  • Nine targeted landing tests passed. The full leonida-gpu crate passed with one test thread, 716 unit cases plus the applicable integration targets. Used the repository's depth-bounds exclusion. The first parallel run failed in watch::many_askers_tests::no_mapping_is_lost_between_askers.
  • Clean-room scan passed on the complete tracked tree before commit.

GPUs tested: Windows host, NVIDIA RTX 5070, driver 621.14. The changed operation and benchmark are CPU work.

AI-assisted: OpenAI Codex (GPT-6), independently reviewed read-only by GPT-6.2 Astra.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5618104721 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3275). Originally posted by [FifthImpact](https://github.com/FifthImpact) on 2026-12-03T01:41:40Z. --- Claimed in the coordination issue as D3D12-LAND-BLOCK-OWNER-LOOKUP ([claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7364356707)). ### What and why When GPU writes land through a second view of game memory, each journal block needs the identity of the one buffer that can take credit for writing it. The previous implementation searched every piece of the job for each block. Index the existing vector once. The normal ordered, distinct case pairs corresponding entries directly. Incomplete or conflicting pieces still preclude credit, and repeated journal notifications keep their original order. The Windows and Wine paths use the same code. ### Tested - Compared the old and new owner loops in an optimized Rust harness on Windows, alternating implementations on identical synthetic inputs. For ordered jobs of 4, 16, 64 and 256 distinct blocks, medians in ns/job were 25→23, 220→48, 2,999→161 and 37,168→649. One block was 7.7→8.3 ns. Four shuffled blocks were 27→31 ns. These measure the lookup only. No in-game FPS result. - The new regression case exercises repeated, unknown and conflicting owners, nonconsecutive arrivals and reverse order. On base the new test failed to compile because the indexing helper was absent. The performance comparison above uses the working base implementation. - Nine targeted landing tests passed. The full leonida-gpu crate passed with one test thread, 716 unit cases plus the applicable integration targets. Used the repository's depth-bounds exclusion. The first parallel run failed in watch::many_askers_tests::no_mapping_is_lost_between_askers. - Clean-room scan passed on the complete tracked tree before commit. GPUs tested: Windows host, NVIDIA RTX 5070, driver 621.14. The changed operation and benchmark are CPU work. AI-assisted: OpenAI Codex (GPT-6), independently reviewed read-only by GPT-6.2 Astra.
merzleckeier commented 2026-12-03 01:50:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T01:50:38Z.

Review: COMMENTED


Rechecked ec94ceb0 merged onto main at d15e048a. The Windows MSVC build passed all nine land::tests:: tests under Wine 11.22, with the benchmark ignored.

I also extracted the exact old and new Notes::flush() implementations and the new index helper into a synthetic Rust harness. I held the journal and the recorded Shadow::landed calls constant. Both versions gave identical ordered call traces and both counters for 2,516,921 combinations, separately with owner credit enabled and disabled. This covers all piece vectors of up to four entries over three block numbers and two owners plus null, and independent journal sequences of up to four observations, including a block with no piece. It exercises missing, conflicting, repeated, reversed and out-of-position observations. The no-page early return also agreed.

As a negative control I removed the block-key check on the positional match in the harness. It diverged immediately when the journal named a different block. These were synthetic checks of the lookup and notification behavior. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6162324009 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3275#pullrequestreview-6162324009). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T01:50:38Z. **Review:** COMMENTED --- Rechecked `ec94ceb0` merged onto `main` at `d15e048a`. The Windows MSVC build passed all nine `land::tests::` tests under Wine 11.22, with the benchmark ignored. I also extracted the exact old and new `Notes::flush()` implementations and the new index helper into a synthetic Rust harness. I held the journal and the recorded `Shadow::landed` calls constant. Both versions gave identical ordered call traces and both counters for 2,516,921 combinations, separately with owner credit enabled and disabled. This covers all piece vectors of up to four entries over three block numbers and two owners plus null, and independent journal sequences of up to four observations, including a block with no piece. It exercises missing, conflicting, repeated, reversed and out-of-position observations. The no-page early return also agreed. As a negative control I removed the block-key check on the positional match in the harness. It diverged immediately when the journal named a different block. These were synthetic checks of the lookup and notification behavior. AI-assisted with OpenAI Codex.
fiestorra commented 2026-12-03 01:51:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T01:51:22Z.


VERIFY-3275 — Windows nativo: red then green en el índice de dueños

Own commit ec94ceb00 — land.rs (+36/−5), land/tests.rs (+23)

Ran at the head

cargo test -p leonida-gpu --lib land     19 passed; 0 failed; 1 ignored
  land::tests::landed_owners_are_unique_per_block_and_keep_conflicts ... ok

Two controls, and only the second bit — the first is worth reporting because it says what the test is not about:

  1. Forcing the sorted fast path off (if false && landed.is_sorted_by(...)): still green — the test's input is already sorted, so the shortcut is not what it measures.
  2. Making the dedup keep the first owner and not mark the conflict (if false instead of if later.1 != first.1):
FAILED: landed_owners_are_unique_per_block_and_keep_conflicts
assertion `left == right` failed

The second bites, and it is the rule the commit adds: one owner per block, and a block written through two different copies keeps no owner — a null that says "this block's copy-back cannot be attributed", rather than silently picking the first writer.

What the change is: the landed pieces are indexed once per job (index_landed — sort and dedup, skipping the sort when the worker jobs already arrive in block order), and the doc comment says who may land out of order: "the worker jobs already arrive in block order; callers landing pieces serially can also visit a block again later."

Why the second half matters more than the first: the sort is a speed-up, the dedup is a correctness rule — and the test pins the rule, not the speed-up, which is why my first control was allowed to be green.

What I could not test

  • The copy-back on a title's frame: no game; the tests drive the index and the conflict marking.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7364811310 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3275#issuecomment-7364811310). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T01:51:22Z. --- ## VERIFY-3275 — Windows nativo: `red then green` en el índice de dueños | | | |---|---| | Own commit | `ec94ceb00` — `land.rs` (+36/−5), `land/tests.rs` (+23) | **Ran at the head** ``` cargo test -p leonida-gpu --lib land 19 passed; 0 failed; 1 ignored land::tests::landed_owners_are_unique_per_block_and_keep_conflicts ... ok ``` **Two controls, and only the second bit — the first is worth reporting because it says what the test is *not* about**: 1. **Forcing the sorted fast path off** (`if false && landed.is_sorted_by(...)`): **still green** — **the test's input is already sorted, so the shortcut is not what it measures.** 2. **Making the dedup keep the first owner and not mark the conflict** (`if false` instead of `if later.1 != first.1`): ``` FAILED: landed_owners_are_unique_per_block_and_keep_conflicts assertion `left == right` failed ``` **The second bites, and it is the rule the commit adds**: **one owner per block, and a block written through two different copies keeps *no* owner** — **a null that says "this block's copy-back cannot be attributed", rather than silently picking the first writer.** **What the change is**: **the landed pieces are indexed once per job** (`index_landed` — **sort and dedup, skipping the sort when the worker jobs already arrive in block order**), **and the doc comment says who may land out of order**: *"the worker jobs already arrive in block order; callers landing pieces serially can also visit a block again later."* **Why the second half matters more than the first**: **the sort is a speed-up, the dedup is a correctness rule** — **and the test pins the rule, not the speed-up, which is why my first control was allowed to be green.** ## What I could not test - **The copy-back on a title's frame**: no game; the tests drive the index and the conflict marking. Written with an AI assistant.
MoonEyes commented 2026-12-03 02:17:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T02:17:26Z.


RUN (in game, batch of two pull requests), each head merged with git merge --no-ff onto main d15e048a7, in one build: #3275 ec94ceb00, #3276 94950d4a5. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 16.8, mean 16.9
Rendered fps, last 120 s median 17.0
Time under 5 fps in the world 0 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used, so the default start (every known pipeline precompiled) was not exercised. #3275 changes how copy-back work is assigned; whether it saves time was not measured here (one run, no A/B), only that nothing fell over. #3276's new keyboard and mouse binds were not exercised: the run's input was the default key route, so it covers the default path only.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365297886 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3275#issuecomment-7365297886). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T02:17:26Z. --- RUN (in game, batch of two pull requests), each head merged with `git merge --no-ff` onto main `d15e048a7`, in one build: #3275 `ec94ceb00`, #3276 `94950d4a5`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, `-PrecompileUsed`, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 16.8, mean 16.9 | | Rendered fps, last 120 s | median 17.0 | | Time under 5 fps in the world | 0 % | For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures; `-PrecompileUsed` was used, so the default start (every known pipeline precompiled) was not exercised. #3275 changes how copy-back work is assigned; whether it saves time was not measured here (one run, no A/B), only that nothing fell over. #3276's new keyboard and mouse binds were not exercised: the run's input was the default key route, so it covers the default path only. AI-assisted (Claude Code).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3275:upstream-pr/3275'
git switch 'upstream-pr/3275'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3275'
git switch 'upstream-pr/3275'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3275'
git switch 'upstream-pr/3275'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3275'
git switch 'main'
git merge --squash 'upstream-pr/3275'
git switch 'main'
git merge --ff-only 'upstream-pr/3275'
git switch 'main'
git merge 'upstream-pr/3275'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3275
No description provided.