fix(hle): opt out of Windows efficiency mode throttling in console timers #3269

Open
legayclightning22 wants to merge 2 commits from upstream-pr/3271 into main
legayclightning22 commented 2026-11-26 15:18:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-26T15:18:59Z.


Summary

Updates use_console_timers in crates/victory-hle/src/runtime.rs so the process opts out of Windows Efficiency Mode throttling by default, keeping timer resolution and frame pacing consistent when unfocused.

Changes

  • Set ControlMask to PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION and keep StateMask at 0 by default to opt out of efficiency throttling.
  • Add VICTORY_EFFICIENCY_MODE=1 support to opt back into efficiency throttling when desired.
  • Log failed SetProcessInformation calls via tracing instead of panicking, and add a unit test for the power-throttling mask logic.

Verification

  • cargo check -p victory-hle --all-targets
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings
  • cargo test -p victory-hle --lib
  • cargo xtask policy
<!-- greyfinch-sync:Marvisak/VIctory:issue:5512653818 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3271). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-26T15:18:59Z. --- ## Summary Updates `use_console_timers` in `crates/victory-hle/src/runtime.rs` so the process opts out of Windows Efficiency Mode throttling by default, keeping timer resolution and frame pacing consistent when unfocused. ## Changes - Set `ControlMask` to `PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION` and keep `StateMask` at `0` by default to opt out of efficiency throttling. - Add `VICTORY_EFFICIENCY_MODE=1` support to opt back into efficiency throttling when desired. - Log failed `SetProcessInformation` calls via `tracing` instead of panicking, and add a unit test for the power-throttling mask logic. ## Verification - `cargo check -p victory-hle --all-targets` - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` - `cargo test -p victory-hle --lib` - `cargo xtask policy` ```[cite: 20, 21]
Dukestar69 commented 2026-11-26 15:51:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:51:36Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64:

  • Opting out of PROCESS_POWER_THROTTLING_EXECUTION_SPEED alongside PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION (with opt-in VICTORY_EFFICIENCY_MODE=1 and VICTORY_HIDDEN_WINDOW=1) and logging warnings when SetProcessInformation/timeBeginPeriod fail is clean and well-tested.
  • cargo test -p victory-hle --lib modules::lifecycle:: -- --test-threads=1: 14 passed, 0 failed (including hidden_window_mode_leaves_normal_windows_alone and hidden_window_mode_moves_and_hides_window_without_touching_size).
  • cargo test -p victory-hle --lib runtime:: -- --test-threads=1: 5 passed, 0 failed (including efficiency_mode_controls_power_throttling_state).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6077062339 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3271#pullrequestreview-6077062339). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T15:51:36Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64: - Opting out of `PROCESS_POWER_THROTTLING_EXECUTION_SPEED` alongside `PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION` (with opt-in `VICTORY_EFFICIENCY_MODE=1` and `VICTORY_HIDDEN_WINDOW=1`) and logging warnings when `SetProcessInformation`/`timeBeginPeriod` fail is clean and well-tested. - `cargo test -p victory-hle --lib modules::lifecycle:: -- --test-threads=1`: 14 passed, 0 failed (including `hidden_window_mode_leaves_normal_windows_alone` and `hidden_window_mode_moves_and_hides_window_without_touching_size`). - `cargo test -p victory-hle --lib runtime:: -- --test-threads=1`: 5 passed, 0 failed (including `efficiency_mode_controls_power_throttling_state`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jackster commented 2026-11-26 22:48:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:48:35Z.


Windows 11, 63bcca4 + this PR:

  • cargo test -p victory-hle lifecycle::: 14 passed / 0 failed.
  • hidden_window_mode (filter): 2 passed — hidden_window_mode_leaves_normal_windows_alone, hidden_window_mode_moves_and_hides_window_without_touching_size.
  • runtime::tests::efficiency_mode_controls_power_throttling_state: 1 passed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.

The two window tests drive apply_hidden_window_mode directly, so no window is created; the efficiency-mode test is #[cfg(windows)] and runs here. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205003522 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3271#issuecomment-7205003522). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:48:35Z. --- Windows 11, `63bcca4` + this PR: - `cargo test -p victory-hle lifecycle::`: 14 passed / 0 failed. - `hidden_window_mode` (filter): 2 passed — `hidden_window_mode_leaves_normal_windows_alone`, `hidden_window_mode_moves_and_hides_window_without_touching_size`. - `runtime::tests::efficiency_mode_controls_power_throttling_state`: 1 passed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. The two window tests drive `apply_hidden_window_mode` directly, so no window is created; the efficiency-mode test is `#[cfg(windows)]` and runs here. Synthetic only. AI-assisted.
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/3271:upstream-pr/3271'
git switch 'upstream-pr/3271'

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/3271'
git switch 'upstream-pr/3271'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3271'
git switch 'upstream-pr/3271'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3271'
git switch 'main'
git merge --squash 'upstream-pr/3271'
git switch 'main'
git merge --ff-only 'upstream-pr/3271'
git switch 'main'
git merge 'upstream-pr/3271'
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
Marvisak/VIctory!3269
No description provided.