frame: skip sleep(Duration::ZERO) on zero-timeout polls #659

Open
Nyutt wants to merge 1 commit from nyutt/merge-frame-no-zero-sleep into post-merge AGit
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on Merge: read from crates/darner-gpu/src/frame.rs. wait_for_frame calls std::thread::sleep(limit) / std::thread::sleep(wait) even when limit == Duration::ZERO (zero-timeout frame polls) or wait == Duration::ZERO (frame already past its tick), yielding the submitting thread's OS quantum unnecessarily.

Port of PR #538 onto Merge: extract sleep_until_tick(wait, limit) and call std::thread::sleep only when the sleep duration is non-zero (!duration.is_zero()).

How it was tested

  • Tested revision: 90cd6e3 (based on origin/Merge 28a9b42)
  • Commands and results: Not yet A/B benchmarked in the game on Merge (unit-tested + clippy-checked).
  • Changes a default: yes, for zero-timeout polls and passed-tick frame waits on Windows.
  • A/B result: not yet measured in-game on Merge.
  • Checks run on that revision:
    • cargo test -p darner-gpu --lib --locked frame::tests -> 1 passed (zero_wait_and_zero_limit_do_not_block), 0 failed
    • cargo clippy -p darner-gpu --lib --locked -> 0 warnings in frame.rs
  • Hardware dependence: likely general (Windows thread scheduler quantum behavior).
  • Coverage gaps: in-game frame-time A/B on Merge.

Checklist

  • I ran this change in the game, or say below why it can't be (verified via unit test & clippy; not yet A/B tested in-game).
  • This PR contains one change based on Merge.
  • The diff contains no game files, code or assets.
  • 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: none found on Merge
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: <!-- paste your !myid here if wanted --> ## What it changes - The problem on `Merge`: read from `crates/darner-gpu/src/frame.rs`. `wait_for_frame` calls `std::thread::sleep(limit)` / `std::thread::sleep(wait)` even when `limit == Duration::ZERO` (zero-timeout frame polls) or `wait == Duration::ZERO` (frame already past its tick), yielding the submitting thread's OS quantum unnecessarily. Port of PR #538 onto `Merge`: extract `sleep_until_tick(wait, limit)` and call `std::thread::sleep` only when the sleep duration is non-zero (`!duration.is_zero()`). ## How it was tested - Tested revision: `90cd6e3` (based on `origin/Merge` `28a9b42`) - Commands and results: Not yet A/B benchmarked in the game on `Merge` (unit-tested + clippy-checked). - Changes a default: yes, for zero-timeout polls and passed-tick frame waits on Windows. - A/B result: not yet measured in-game on `Merge`. - Checks run on that revision: - `cargo test -p darner-gpu --lib --locked frame::tests` -> 1 passed (`zero_wait_and_zero_limit_do_not_block`), 0 failed - `cargo clippy -p darner-gpu --lib --locked` -> 0 warnings in `frame.rs` - Hardware dependence: likely general (Windows thread scheduler quantum behavior). - Coverage gaps: in-game frame-time A/B on `Merge`. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (verified via unit test & clippy; not yet A/B tested in-game). - [x] This PR contains one change based on `Merge`. - [x] The diff contains no game files, code or assets. - [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: none found on `Merge` - Replaces or overlaps: none found
TrustNo1 changed title from [pr-performance][rendering] frame: skip sleep(Duration::ZERO) on zero-timeout polls to frame: skip sleep(Duration::ZERO) on zero-timeout polls 2026-12-06 03:25:28 +00:00
This pull request can be merged automatically.
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 origin '+refs/pull/659/head:nyutt/merge-frame-no-zero-sleep'
git switch 'nyutt/merge-frame-no-zero-sleep'

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 'post-merge'
git merge --no-ff 'nyutt/merge-frame-no-zero-sleep'
git switch 'nyutt/merge-frame-no-zero-sleep'
git rebase 'post-merge'
git switch 'post-merge'
git merge --ff-only 'nyutt/merge-frame-no-zero-sleep'
git switch 'nyutt/merge-frame-no-zero-sleep'
git rebase 'post-merge'
git switch 'post-merge'
git merge --no-ff 'nyutt/merge-frame-no-zero-sleep'
git switch 'post-merge'
git merge --squash 'nyutt/merge-frame-no-zero-sleep'
git switch 'post-merge'
git merge --ff-only 'nyutt/merge-frame-no-zero-sleep'
git switch 'post-merge'
git merge 'nyutt/merge-frame-no-zero-sleep'
git push origin 'post-merge'
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!659
No description provided.