compilemem: skip learning when private bytes are unavailable (#2408) #2586

Open
fainty0 wants to merge 1 commit from upstream-pr/2586 into main
fainty0 commented 2026-11-29 14:40:11 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fainty0 on 2026-11-29T14:40:11Z.


Fixes #2408

What it changes

Wine can return a short response and leave PrivateUsage unwritten. Check the returned size and a sentinel; skip estimator updates when either endpoint is unavailable, but still retire the compile. Genuine zero remains valid. Do not substitute PagefileUsage: on Wine the issue's synthetic control saw it rise only after touching the pages, not on commit.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): none; no GPU or game.
  • Before: the short response was read as zero; the estimator could learn a zero-byte compile from missing data.
  • After: host unit test passed for full, short, unwritten and genuine-zero responses. Windows-target Clippy was compared against clean 829188e: default 5→5 and all-features 4→4 with --keep-going, no added or removed diagnostics. GPU-only Clippy also had no diagnostic changes. Staged asset policy passed.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): not applicable.
  • cargo test passed for the crates it touches: no. The isolated parser unit test passed via rustc --test; full Linux workspace tests are blocked by existing Windows-only imports. Windows tests not run (no Windows); no Proton/runtime verification.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1182 (merged, memory example only), #2148 (RT builder retry), #2392 (system commit accounting). None changes the production compile-memory estimator. #2408's author mentions a candidate, but searches for a linked/open fix found none.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5551771333 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2586). Originally posted by [fainty0](https://github.com/fainty0) on 2026-11-29T14:40:11Z. --- Fixes #2408 ## What it changes Wine can return a short response and leave `PrivateUsage` unwritten. Check the returned size and a sentinel; skip estimator updates when either endpoint is unavailable, but still retire the compile. Genuine zero remains valid. Do not substitute `PagefileUsage`: on Wine the issue's synthetic control saw it rise only after touching the pages, not on commit. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): none; no GPU or game. - Before: the short response was read as zero; the estimator could learn a zero-byte compile from missing data. - After: host unit test passed for full, short, unwritten and genuine-zero responses. Windows-target Clippy was compared against clean `829188e`: default 5→5 and all-features 4→4 with `--keep-going`, no added or removed diagnostics. GPU-only Clippy also had no diagnostic changes. Staged asset policy passed. - For shader changes, the wave sizes tested (32 and/or 64 lanes): not applicable. - `cargo test` passed for the crates it touches: no. The isolated parser unit test passed via `rustc --test`; full Linux workspace tests are blocked by existing Windows-only imports. Windows tests not run (no Windows); no Proton/runtime verification. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1182 (merged, memory example only), #2148 (RT builder retry), #2392 (system commit accounting). None changes the production compile-memory estimator. #2408's author mentions a candidate, but searches for a linked/open fix found none.
fretuil commented 2026-11-29 14:43:55 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fretuil on 2026-11-29T14:43:55Z.

Review: APPROVED


Reviewed a1f619d — looks solid and well-tested overall.

What looks good:

  • Handling partial PROCESS_MEMORY_COUNTERS_EX responses via both the returned cb size check and the UNWRITTEN sentinel safely covers both ways Wine can leave PrivateUsage unpopulated.
  • Retiring compiles in State::finish when either endpoint is None prevents polluting the estimator while keeping finished counters accurate.
  • Tightening Process and process_memory visibility to module-private and adding unit tests for short cb responses and missing endpoints is very clean.

Minor nits (optional):

  • In State::try_start, initializing peak_private: private.unwrap_or(0) instead of 0 would keep peak_private >= private_at_start true before the first sample() call (even though saturating_sub in finish already produces the right result).
  • In line(), when p.private is None, the log reads "process unavailable private"; "process N/A private" or "process private unavailable" might scan a bit more naturally in logs.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6103357590 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2586#pullrequestreview-6103357590). Originally posted by [fretuil](https://github.com/fretuil) on 2026-11-29T14:43:55Z. **Review:** APPROVED --- Reviewed `a1f619d` — looks solid and well-tested overall. **What looks good:** - Handling partial `PROCESS_MEMORY_COUNTERS_EX` responses via both the returned `cb` size check and the `UNWRITTEN` sentinel safely covers both ways Wine can leave `PrivateUsage` unpopulated. - Retiring compiles in `State::finish` when either endpoint is `None` prevents polluting the estimator while keeping `finished` counters accurate. - Tightening `Process` and `process_memory` visibility to module-private and adding unit tests for short `cb` responses and missing endpoints is very clean. **Minor nits (optional):** - In `State::try_start`, initializing `peak_private: private.unwrap_or(0)` instead of `0` would keep `peak_private >= private_at_start` true before the first `sample()` call (even though `saturating_sub` in `finish` already produces the right result). - In `line()`, when `p.private` is `None`, the log reads `"process unavailable private"`; `"process N/A private"` or `"process private unavailable"` might scan a bit more naturally in logs.
ArturoWolff commented 2026-11-30 18:38:07 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ArturoWolff on 2026-11-30T18:38:07Z.


Thanks for addressing #2408. I checked your exact head 76fe0e0ea8c43af5da559a21d13a25ecc247cf01 against current main 84bd61e2c73e84933796bf8ede1a3343e64b26b1. The returned-size/sentinel check and optional endpoints work in a controlled test of the actual reader and estimator logic.

One thing to preserve when bringing this forward to main: 64818e37 changed State::finish to subtract max(private_at_start, private_now), excluding persistent growth. Your branch predates that change, so this is a rebase/integration concern, not a new defect introduced by your PR.

I compiled the exact extracted reader, State, Estimator, admission logic and locked counter layouts for both revisions with Rust 1.98.1. Both used the same 11 behavioural tests. The Windows API response fields were supplied by a deterministic CPU-only fixture; these are not new live Wine API observations or allocated multi-GiB buffers.

Controlled scenario Current main Your head Local adaptation
Four short successful intervals: learned samples 4 0 0
Resulting reservation 256 MiB 1024 MiB 1024 MiB
Subsequent admissions (same memory figures) 5 2 2
Persistent growth: start 10 GiB, peak/end 17 GiB 0 7 GiB 0
Start 10 GiB, peak 17.5 GiB, end 17 GiB 512 MiB 7.5 GiB 512 MiB
Two overlapping compiles: start 10 GiB, peak 18 GiB, ends 17/16 GiB 512/1024 MiB 4096/4096 MiB 512/1024 MiB

The admission fixture uses physical 16 GiB, free physical 2 GiB, free commit 32 GiB and the receiver's unchanged default floors. The common contract passed 7/11 on each original arm: main failed four counter-validity cases, your head failed four current-main transient-accounting cases. The local adaptation keeps your parser, uses optional endpoints with normal interval retirement, and retains main's max(start,end) baseline. It passed all 25 extracted tests (14 source tests, including the parser, plus the same 11 contract cases) with rustc --test -D warnings.

I would keep the existing persistent-growth, fast-compile and overlap tests from 64818e37 when updating this PR, along with the missing-counter and genuine-zero tests. The earlier real GE-Proton 11-14 ABI evidence remains in #2408. The new comparison is an isolated source-level regression check: I have not run the adapted full crate, native Windows, or a new retail comparison. No gameplay/FPS or host-OOM fix is established by it.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7288140458 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2586#issuecomment-7288140458). Originally posted by [ArturoWolff](https://github.com/ArturoWolff) on 2026-11-30T18:38:07Z. --- Thanks for addressing #2408. I checked your exact head `76fe0e0ea8c43af5da559a21d13a25ecc247cf01` against current main `84bd61e2c73e84933796bf8ede1a3343e64b26b1`. The returned-size/sentinel check and optional endpoints work in a controlled test of the actual reader and estimator logic. One thing to preserve when bringing this forward to main: [64818e37](https://github.com/trustno1-coder/VIctory-NVIDIA/commit/64818e37960d0c040d50da923836ef19eb224b38) changed `State::finish` to subtract `max(private_at_start, private_now)`, excluding persistent growth. Your branch predates that change, so this is a rebase/integration concern, not a new defect introduced by your PR. I compiled the exact extracted reader, State, Estimator, admission logic and locked counter layouts for both revisions with Rust 1.98.1. Both used the same 11 behavioural tests. The Windows API response fields were supplied by a deterministic CPU-only fixture; these are not new live Wine API observations or allocated multi-GiB buffers. | Controlled scenario | Current main | Your head | Local adaptation | |---|---:|---:|---:| | Four short successful intervals: learned samples | 4 | 0 | 0 | | Resulting reservation | 256 MiB | 1024 MiB | 1024 MiB | | Subsequent admissions (same memory figures) | 5 | 2 | 2 | | Persistent growth: start 10 GiB, peak/end 17 GiB | 0 | 7 GiB | 0 | | Start 10 GiB, peak 17.5 GiB, end 17 GiB | 512 MiB | 7.5 GiB | 512 MiB | | Two overlapping compiles: start 10 GiB, peak 18 GiB, ends 17/16 GiB | 512/1024 MiB | 4096/4096 MiB | 512/1024 MiB | The admission fixture uses physical 16 GiB, free physical 2 GiB, free commit 32 GiB and the receiver's unchanged default floors. The common contract passed 7/11 on each original arm: main failed four counter-validity cases, your head failed four current-main transient-accounting cases. The local adaptation keeps your parser, uses optional endpoints with normal interval retirement, and retains main's `max(start,end)` baseline. It passed all 25 extracted tests (14 source tests, including the parser, plus the same 11 contract cases) with `rustc --test -D warnings`. I would keep the existing persistent-growth, fast-compile and overlap tests from 64818e37 when updating this PR, along with the missing-counter and genuine-zero tests. The earlier real GE-Proton 11-14 ABI evidence remains in [#2408](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2408). The new comparison is an isolated source-level regression check: I have not run the adapted full crate, native Windows, or a new retail comparison. No gameplay/FPS or host-OOM fix is established by it. AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).
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/2586:upstream-pr/2586'
git switch 'upstream-pr/2586'

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/2586'
git switch 'upstream-pr/2586'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2586'
git switch 'upstream-pr/2586'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2586'
git switch 'main'
git merge --squash 'upstream-pr/2586'
git switch 'main'
git merge --ff-only 'upstream-pr/2586'
git switch 'main'
git merge 'upstream-pr/2586'
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
trustno1-coder/VIctory-NVIDIA!2586
No description provided.