profile: report late and expired profiling windows accurately #316

Manually merged
github merged 2 commits from github-bot/gh-316 into a-publier 2026-11-27 00:57:58 +00:00 AGit
Owner

@⁠battledogegames-design on GitHub · 2026-11-26 19:55 UTC · original
battledogegames-design:patch-1 → a-publier · +191 −2 · 1 files · 2 commits · merged 2026-11-26 22:30 UTC

Fixes #284 (reported by @⁠itsonewi — thank you for the careful write-up).

profile_on_schedule measures every VICTORY_PROFILE window against the one start and runs them one after another in a single thread. That scheduling is unchanged by this PR. What changes is that its outcomes are no longer silent:

  • Late window — a window whose turn comes after its from (an earlier profile ran into it) samples only the rest of its window. It now says so when it begins: the profile in <file> begins late (at X s of F to T s): it covers only the rest of its window.
  • Expired window — a window whose turn comes at or after its to sampled nothing, but still wrote a rounds 0 file and printed the profile is in <file>. It now writes nothing and reports: no profile is in <file>: its window (F to T s) had already passed when its turn came. If a file from an earlier run already exists at that name, it is left byte-for-byte untouched and the message says so (no new profile is in <file>: …; the file there is from an earlier run and was not touched), so stale output cannot be mistaken for this run's.
  • Unreadable entries — an entry in the ; list that cannot be read as a window was dropped by filter_map without a word. It is now named once: a profile was not understood and is skipped: <entry>. Empty entries (e.g. from a trailing ;) are still ignored.

Semantics preserved

  • from/to remain absolute times from the one start, as documented and as VICTORY_STACKS uses its times. The relative re-measurement floated in #284 (sleep from, then sample to − from) was deliberately not adopted: it would silently change what existing schedules mean.
  • Windows still run sequentially in one thread; no concurrent sampling.
  • Parsing rules (asked()), the output file format, and the success message for windows that actually sample are unchanged.
  • Windows that begin on time behave exactly as before.

Implementation

One file, crates/victory-loader/src/profile.rs. The window's standing when its turn comes is judged by a small pure function, turn(from, to, now) -> OnTime | Late | Elapsed; list parsing moves into schedule(), which returns the unreadable entries alongside the windows so they can be named. No scheduling code is reordered or altered.

Tests

Deterministic tests in the module (the module requires --features diagnostics):

  • a_windows_turn_is_judged_against_the_one_start — pure classification: single window, sequential non-overlapping windows, partial overlap, complete overlap, deadline reached/passed.
  • a_schedule_reads_its_windows_and_names_the_rest — pure parsing: valid windows kept, invalid entries returned for naming, empty input/entries.
  • a_window_that_has_already_passed_writes_no_profile — behavioural regression test: fails before this change (the expired window wrote a file and reported success), passes after.
  • a_window_that_has_already_passed_leaves_an_earlier_file_alone — an earlier run's file at the same name is neither truncated nor overwritten.
  • a_window_that_begins_late_samples_until_its_deadline — control: passes before and after; pins the sampling behaviour the change must not alter.
  • The pre-existing parsing test is untouched.

Validation (exact environment — read the caveat)

Executed by the author on Linux (Ubuntu 24.04) with Rust stable, target x86_64-pc-windows-gnu, the PE test binaries run under Wine 9.0 (MinGW toolchain). This is real execution of the real test binaries, but it is not native Windows validation; a native run remains the final confirmation for the thread-sampling paths.

  • Baseline (unmodified code + the new behavioural tests): profile:: — 2 passed, 1 failed (the expired-window test; output shows the profile is in … printed for the empty profile). Full victory-loader suite: 55 passed, that test the only failure.
  • With this change: profile:: — 6 passed. Full victory-loader suite (cargo test -p victory-loader --features diagnostics): 59 passed, 0 failed (two of three runs; see flake note).
  • Clippy: no warnings in profile.rs (two pre-existing warnings in descriptor_sites.rs).

Known unrelated flake: publish::tests::concurrent_publishers_do_not_share_a_staging_file fails intermittently under Wine on both the unmodified and patched binaries (filesystem-timing sensitivity); it does not touch this module and the patched suite passed 59/59 in two of three full runs. Flagging it here so it is not mistaken for a regression from this change.

No performance claims: this is a profiler-correctness change. Its only runtime cost is a message in cases that previously printed a different one, and an early return that skips writing an empty file.

**@⁠battledogegames-design** on GitHub · 2026-11-26 19:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/316) `battledogegames-design:patch-1` → `a-publier` · +191 −2 · 1 files · 2 commits · merged 2026-11-26 22:30 UTC Fixes #284 (reported by @⁠itsonewi — thank you for the careful write-up). `profile_on_schedule` measures every `VICTORY_PROFILE` window against the one start and runs them one after another in a single thread. That scheduling is **unchanged** by this PR. What changes is that its outcomes are no longer silent: - **Late window** — a window whose turn comes after its `from` (an earlier profile ran into it) samples only the rest of its window. It now says so when it begins: `the profile in <file> begins late (at X s of F to T s): it covers only the rest of its window`. - **Expired window** — a window whose turn comes at or after its `to` sampled nothing, but still wrote a `rounds 0` file and printed `the profile is in <file>`. It now writes nothing and reports: `no profile is in <file>: its window (F to T s) had already passed when its turn came`. If a file from an earlier run already exists at that name, it is left byte-for-byte untouched and the message says so (`no new profile is in <file>: …; the file there is from an earlier run and was not touched`), so stale output cannot be mistaken for this run's. - **Unreadable entries** — an entry in the `;` list that cannot be read as a window was dropped by `filter_map` without a word. It is now named once: `a profile was not understood and is skipped: <entry>`. Empty entries (e.g. from a trailing `;`) are still ignored. ## Semantics preserved - `from`/`to` remain **absolute** times from the one start, as documented and as `VICTORY_STACKS` uses its times. The relative re-measurement floated in #284 (sleep `from`, then sample `to − from`) was deliberately **not** adopted: it would silently change what existing schedules mean. - Windows still run sequentially in one thread; no concurrent sampling. - Parsing rules (`asked()`), the output file format, and the success message for windows that actually sample are unchanged. - Windows that begin on time behave exactly as before. ## Implementation One file, `crates/victory-loader/src/profile.rs`. The window's standing when its turn comes is judged by a small pure function, `turn(from, to, now) -> OnTime | Late | Elapsed`; list parsing moves into `schedule()`, which returns the unreadable entries alongside the windows so they can be named. No scheduling code is reordered or altered. ## Tests Deterministic tests in the module (the module requires `--features diagnostics`): - `a_windows_turn_is_judged_against_the_one_start` — pure classification: single window, sequential non-overlapping windows, partial overlap, complete overlap, deadline reached/passed. - `a_schedule_reads_its_windows_and_names_the_rest` — pure parsing: valid windows kept, invalid entries returned for naming, empty input/entries. - `a_window_that_has_already_passed_writes_no_profile` — behavioural regression test: **fails before this change** (the expired window wrote a file and reported success), passes after. - `a_window_that_has_already_passed_leaves_an_earlier_file_alone` — an earlier run's file at the same name is neither truncated nor overwritten. - `a_window_that_begins_late_samples_until_its_deadline` — control: passes before and after; pins the sampling behaviour the change must not alter. - The pre-existing parsing test is untouched. ## Validation (exact environment — read the caveat) Executed by the author on Linux (Ubuntu 24.04) with Rust stable, target `x86_64-pc-windows-gnu`, the PE test binaries **run under Wine 9.0** (MinGW toolchain). This is real execution of the real test binaries, but it is **not native Windows validation**; a native run remains the final confirmation for the thread-sampling paths. - Baseline (unmodified code + the new behavioural tests): `profile::` — 2 passed, **1 failed** (the expired-window test; output shows `the profile is in …` printed for the empty profile). Full `victory-loader` suite: 55 passed, that test the only failure. - With this change: `profile::` — **6 passed**. Full `victory-loader` suite (`cargo test -p victory-loader --features diagnostics`): **59 passed, 0 failed** (two of three runs; see flake note). - Clippy: no warnings in `profile.rs` (two pre-existing warnings in `descriptor_sites.rs`). Known unrelated flake: `publish::tests::concurrent_publishers_do_not_share_a_staging_file` fails intermittently **under Wine** on both the unmodified and patched binaries (filesystem-timing sensitivity); it does not touch this module and the patched suite passed 59/59 in two of three full runs. Flagging it here so it is not mistaken for a regression from this change. No performance claims: this is a profiler-correctness change. Its only runtime cost is a message in cases that previously printed a different one, and an early return that skips writing an empty file.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:59:07 +00:00
github manually merged commit 751618c718 into a-publier 2026-11-27 00:57:58 +00:00
Author
Owner

@⁠battledogegames-design on GitHub · 2026-11-27 00:33 UTC · original

Post-merge native Windows validation of PR #316 at f865d0bf is complete. The base (cd8dfc06) reproduced both expired-window failures: it created a misleading zero-round profile and overwrote an earlier run's file.

The corrected implementation passed all six profiler tests and the complete loader diagnostics suite (59 unit and 3 integration tests). The concurrent-publisher test passed in 50 fresh processes on each revision.

We also verified that profile.rs is byte-identical at the PR head f865d0bf, merge commit 751618c7, and verified upstream tip 4eb6cfdf.

A separate public-scheduler probe confirmed that overlapping windows retain their original absolute deadline. The second window, scheduled for 300–800 ms, began at 603–609 ms and its last samples fell at 798–799 ms across three runs.

One minor reporting nuance: the otherwise on-time first window printed begins late in all three runs because lateness is classified after waking from the scheduled sleep. The observed sampling schedule remained correct. This is a diagnostic reporting nuance, not a demonstrated scheduling correctness defect.

Validation environment: Native Windows build 26300, Rust 1.98.1 MSVC. Offline full-workspace dependency resolution was blocked by an unavailable zlib-rs package in the unrelated game crate. The loader and its two internal dependencies were therefore built in isolation. All 59 retained registry entries matched the original lockfile, and the complete loader diagnostics suite, including its synthetic integration fixture, executed successfully.

AI-assisted development: Nyx (Claude, Anthropic). Independent native Windows validation: Astra 6.2 (OpenAI).

**@⁠battledogegames-design** on GitHub · 2026-11-27 00:33 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/316#issuecomment-7206565906) Post-merge native Windows validation of PR #316 at `f865d0bf` is complete. The base (`cd8dfc06`) reproduced both expired-window failures: it created a misleading zero-round profile and overwrote an earlier run's file. The corrected implementation passed all six profiler tests and the complete loader diagnostics suite (59 unit and 3 integration tests). The concurrent-publisher test passed in 50 fresh processes on each revision. We also verified that `profile.rs` is byte-identical at the PR head `f865d0bf`, merge commit `751618c7`, and verified upstream tip `4eb6cfdf`. A separate public-scheduler probe confirmed that overlapping windows retain their original absolute deadline. The second window, scheduled for 300–800 ms, began at 603–609 ms and its last samples fell at 798–799 ms across three runs. One minor reporting nuance: the otherwise on-time first window printed `begins late` in all three runs because lateness is classified after waking from the scheduled sleep. The observed sampling schedule remained correct. This is a diagnostic reporting nuance, not a demonstrated scheduling correctness defect. **Validation environment:** Native Windows build 26300, Rust 1.98.1 MSVC. Offline full-workspace dependency resolution was blocked by an unavailable `zlib-rs` package in the unrelated game crate. The loader and its two internal dependencies were therefore built in isolation. All 59 retained registry entries matched the original lockfile, and the complete loader diagnostics suite, including its synthetic integration fixture, executed successfully. **AI-assisted development: Nyx (Claude, Anthropic). Independent native Windows validation: Astra 6.2 (OpenAI).**
This discussion has been locked. Commenting is limited to contributors.
No description provided.