darner-gpu: a single free tile goes before a long run is cut #643

Open
qnjk wants to merge 1 commit from qnjk/Darner:tiles-take-doc into Main
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: take's comment said the tiles come from a heap "the lowest free tiles first (single free tiles are used up before a long run is cut)" (crates/darner-gpu/src/tiles.rs:160-163), but the cut was h.free.first() whatever the run's length: with runs [(0, 300), (400, 1)] and two tiles wanted, two tiles came off the 300-tile run and the single tile stayed free. The pool wants long runs — the largest level given is 256 tiles of a 1024-tile heap, and a heap goes back to the card only when every one of its tiles is free, so a tile taken from a long run is a tile that run no longer has.

  • This change takes the shortest run first, the lowest of equals, so a long run is cut only by what no shorter run can give; the cut run still keeps its higher end, as before, so the free runs stay in order. The choice is a pure pick beside take, testable without a device, and take's comment now names the rule the code follows.

How it was tested

  • Tested revision: 6e5f6db (one commit on c8258f9).
  • Commands and results:
    • cargo test --locked -p darner-gpu --lib -- tiles — 17 passed, 0 failed, 6 ignored.
    • New test on pick: the [(0, 300), (400, 1)] case above takes the single tile first, then the run; equal-length runs take the lowest; a run that exactly covers the request is preferred over a longer one.
    • Fail-before, with the old h.free.first() choice restored: the first assertion fails with the two tiles taken from the long run, which is the behaviour the comment already denied.
    • cargo clippy --locked -p darner-gpu --all-targets -- -D warnings passes.
  • Changes a default: no. Which tiles a placement gets does change (that is the fix), but the pool's size, the heap accounting and the API do not.
  • A/B result: not applicable — no default change and no speed claim; the effect is fragmentation, not frame time. Fragmentation of this pool is what the finding measures by reasoning, not by a run.
  • Gates run on that revision:
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: passes.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.
    • Gate 3: the crate's tiles tests are green; the whole-workspace run is not green on this machine for the pre-existing darner-gpu reasons (#224, #150), which this does not touch.
  • Gameplay, when relevant: no gameplay run. The change affects which tiles a level is placed in; no visual or frame-rate claim is made.
  • Shader wave sizes tested, when relevant: not applicable.
  • Hardware dependence: none.
  • Coverage gaps: the heap search and the cut itself are not exercised (they need a device); only the pure choice is. The other finding in the same report (64 MiB heaps made with no card-room check) is a separate change.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not run in gameplay: a placement change cannot be shown by a short run, and no figure is claimed. The evidence is the test, which fails on main.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md (cargo xtask policy: passes).
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #57 changes crates/darner-gpu/src/tiles.rs (it adds before_send calls); this change touches take's choice and the comment only. No open or closed issue mentions the tile pool's run choice.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: `take`'s comment said the tiles come from a heap "the lowest free tiles first (single free tiles are used up before a long run is cut)" (`crates/darner-gpu/src/tiles.rs:160-163`), but the cut was `h.free.first()` whatever the run's length: with runs `[(0, 300), (400, 1)]` and two tiles wanted, two tiles came off the 300-tile run and the single tile stayed free. The pool wants long runs — the largest level given is 256 tiles of a 1024-tile heap, and a heap goes back to the card only when every one of its tiles is free, so a tile taken from a long run is a tile that run no longer has. - This change takes the **shortest** run first, the lowest of equals, so a long run is cut only by what no shorter run can give; the cut run still keeps its higher end, as before, so the free runs stay in order. The choice is a pure `pick` beside `take`, testable without a device, and `take`'s comment now names the rule the code follows. ## How it was tested - Tested revision: `6e5f6db` (one commit on `c8258f9`). - Commands and results: - `cargo test --locked -p darner-gpu --lib -- tiles` — 17 passed, 0 failed, 6 ignored. - New test on `pick`: the `[(0, 300), (400, 1)]` case above takes the single tile first, then the run; equal-length runs take the lowest; a run that exactly covers the request is preferred over a longer one. - Fail-before, with the old `h.free.first()` choice restored: the first assertion fails with the two tiles taken from the long run, which is the behaviour the comment already denied. - `cargo clippy --locked -p darner-gpu --all-targets -- -D warnings` passes. - Changes a default: no. Which tiles a placement gets does change (that is the fix), but the pool's size, the heap accounting and the API do not. - A/B result: not applicable — no default change and no speed claim; the effect is fragmentation, not frame time. Fragmentation of this pool is what the finding measures by reasoning, not by a run. - Gates run on that revision: - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: passes. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passes. - Gate 3: the crate's `tiles` tests are green; the whole-workspace run is not green on this machine for the pre-existing `darner-gpu` reasons (#224, #150), which this does not touch. - Gameplay, when relevant: no gameplay run. The change affects which tiles a level is placed in; no visual or frame-rate claim is made. - Shader wave sizes tested, when relevant: not applicable. - Hardware dependence: none. - Coverage gaps: the heap search and the cut itself are not exercised (they need a device); only the pure choice is. The other finding in the same report (64 MiB heaps made with no card-room check) is a separate change. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - Not run in gameplay: a placement change cannot be shown by a short run, and no figure is claimed. The evidence is the test, which fails on `main`. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: passes). - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #57 changes `crates/darner-gpu/src/tiles.rs` (it adds `before_send` calls); this change touches `take`'s choice and the comment only. No open or closed issue mentions the tile pool's run choice. - Replaces or overlaps: none found
`take`'s comment said the tiles come from a heap "the lowest free tiles
first (single free tiles are used up before a long run is cut)", but the cut
was `h.free.first()` whatever the run's length: with runs [(0, 300),
(400, 1)] and two tiles wanted, two tiles came off the 300-tile run and the
single tile stayed free. The pool wants long runs: the largest level given
is 256 tiles of a 1024-tile heap, and a heap goes back to the card only when
every one of its tiles is free, so a tile taken from a long run is a tile
that run no longer has.

The shortest run is taken first now, the lowest of equals, so that a long
run is cut only by what no shorter run can give; the cut run still keeps its
higher end, as before, so the free runs stay in order. The choice is `pick`,
a pure function beside `take`, so that it can be tested without a device;
`take` keeps the heap search, and its comment names the rule the code
follows.
TrustNo1 changed title from [pr-fix][rendering] darner-gpu: a single free tile goes before a long run is cut to darner-gpu: a single free tile goes before a long run is cut 2026-12-06 03:25:39 +00:00
Owner

Test needed — commit 6e5f6db9; what to check:

  • The problem on main: take's comment said the tiles come from a heap "the lowest free tiles first (single free tiles are used up before a long run is cut)" (crates/darner-gpu/src/tiles.rs:160-163), but the cut was h.free.first() whatever the run's length: with runs [(0, 300), (400, 1)] and two tiles wanted, two tiles came off the 300-tile run and the single tile stayed free. The pool wants long runs — the largest level given is 256 tiles of a 1024-tile heap, and a heap goes back to the card only when every one of its tiles is free, so a tile taken from a long run is a tile that run no longer has.

  • This change takes the shortest run first, the lowest of equals, so a long run is cut only by what no shorter run can give; the cut run still keeps its higher end, as before, so the free runs stay in order. The choice is a pure pick beside take, testable without a device, and take's comment now names the rule the code follows.

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `6e5f6db9`; what to check: - The problem on main: `take`'s comment said the tiles come from a heap "the lowest free tiles first (single free tiles are used up before a long run is cut)" (`crates/darner-gpu/src/tiles.rs:160-163`), but the cut was `h.free.first()` whatever the run's length: with runs `[(0, 300), (400, 1)]` and two tiles wanted, two tiles came off the 300-tile run and the single tile stayed free. The pool wants long runs — the largest level given is 256 tiles of a 1024-tile heap, and a heap goes back to the card only when every one of its tiles is free, so a tile taken from a long run is a tile that run no longer has. - This change takes the **shortest** run first, the lowest of equals, so a long run is cut only by what no shorter run can give; the cut run still keeps its higher end, as before, so the free runs stay in order. The choice is a pure `pick` beside `take`, testable without a device, and `take`'s comment now names the rule the code follows. Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'tiles-take-doc:qnjk-tiles-take-doc'
git switch 'qnjk-tiles-take-doc'

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 'qnjk-tiles-take-doc'
git switch 'qnjk-tiles-take-doc'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'qnjk-tiles-take-doc'
git switch 'qnjk-tiles-take-doc'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'qnjk-tiles-take-doc'
git switch 'Main'
git merge --squash 'qnjk-tiles-take-doc'
git switch 'Main'
git merge --ff-only 'qnjk-tiles-take-doc'
git switch 'Main'
git merge 'qnjk-tiles-take-doc'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!643
No description provided.