Check a texture for writes without building lists #32

Open
romainhedouin wants to merge 1 commit from upstream-pr/32 into a-publier
romainhedouin commented 2026-11-25 12:32:50 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by romainhedouin on 2026-11-25T12:32:50Z.


A sampled texture's refresh (texture.rs, twice in refresh_timed) only asks "was a page of my memory written since I last looked?", but watch::writes built a list of every noted page in the range for it to scan. The new watch::written_since answers from the same asking, looking at the journal in place under the same locks, and stops at the first newer page; writes now goes through the same code and answers exactly as before.

Per texture check, K noted pages in range, answered from the journal Before After
Allocations (model, counted) 2 (K ≤ 4), 4 (K = 16), 6 (K = 64) 1
Model benchmark, K = 16 136–150 ns 47–49 ns
Model benchmark, K = 64 334–348 ns 112–114 ns

"Model benchmark" = a-publier's Notes::each/range copied into a standalone program, unchanged texture (no newer page, so the whole range is scanned), timed in release on a Mac, not in the game. The one allocation left is the journal's pieces list, which this PR doesn't touch. Kernel askings are unchanged.

Tested: Windows clippy (with and without --all-features) adds no warnings, and an assertion for written_since is added to written_pages_are_reported_to_every_asker; watch.rs and texture.rs are Windows-only, so nothing ran here.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5491388933 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/32). Originally posted by [romainhedouin](https://github.com/romainhedouin) on 2026-11-25T12:32:50Z. --- A sampled texture's refresh (texture.rs, twice in `refresh_timed`) only asks "was a page of my memory written since I last looked?", but `watch::writes` built a list of every noted page in the range for it to scan. The new `watch::written_since` answers from the same asking, looking at the journal in place under the same locks, and stops at the first newer page; `writes` now goes through the same code and answers exactly as before. | Per texture check, K noted pages in range, answered from the journal | Before | After | |---|---|---| | Allocations (model, counted) | 2 (K ≤ 4), 4 (K = 16), 6 (K = 64) | 1 | | Model benchmark, K = 16 | 136–150 ns | 47–49 ns | | Model benchmark, K = 64 | 334–348 ns | 112–114 ns | "Model benchmark" = a-publier's `Notes::each`/`range` copied into a standalone program, unchanged texture (no newer page, so the whole range is scanned), timed in release on a Mac, not in the game. The one allocation left is the journal's `pieces` list, which this PR doesn't touch. Kernel askings are unchanged. Tested: Windows clippy (with and without `--all-features`) adds no warnings, and an assertion for `written_since` is added to `written_pages_are_reported_to_every_asker`; watch.rs and texture.rs are Windows-only, so nothing ran here. 🤖 Generated with [Claude Code](https://claude.com/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/32:upstream-pr/32'
git switch 'upstream-pr/32'

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 'a-publier'
git merge --no-ff 'upstream-pr/32'
git switch 'upstream-pr/32'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/32'
git switch 'upstream-pr/32'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/32'
git switch 'a-publier'
git merge --squash 'upstream-pr/32'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/32'
git switch 'a-publier'
git merge 'upstream-pr/32'
git push origin 'a-publier'
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
Belobug/VIctory-Belobug-AMD!32
No description provided.