reprend #2031: runtime: harden submit_phases period parsing and skip Scope overhead when disabled #2738

Merged
leonida/mandy
OreoFR merged 6 commits from carry/pr-2031 into main 2026-11-30 17:15:35 +00:00

Pull request successfully merged and closed

OreoFR commented 2026-11-30 13:39:44 +00:00

Carries #2031 by @IlyassRS3, because it conflicts with main after #2566 and the reminder to merge main (https://github.com/ProjectLeonida/mandy/pull/2031#issuecomment-7232642471) got no answer within the delay of the carry rule. If the author comes back, this carry is dropped.

Item: RT-SUBMIT-PHASES-PERIOD-PARSE-AND-ZERO-OVERHEAD-SCOPE-CARRY (claimed in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7280119323; original item RT-SUBMIT-PHASES-PERIOD-PARSE-AND-ZERO-OVERHEAD-SCOPE).

What this branch is

  • The author's branch at ed34b996c, unchanged (no rebase, author commits kept).
  • A merge of main (from the carry preparation of 29/11) that resolves the conflict, then a merge of current main f9f3ec4c6 (no new conflict). Both merge commits carry Co-authored-by the author.
  • Nothing else: the change itself is the original PR's; see #2031 for what and why, and the verifications posted there.

What conflicted and how it was resolved

  • runtime/src/submit_phases.h: main's Scope (nested phases, active phase) kept. The PR's skip now applies only when nobody reads the times: timing_wanted() is period 0 and LEONIDA_DEV_OVERLAY not 1, because main's dev overlay reads these totals and the active phase.

Design choice for a human: the PR's zero-overhead skip is narrowed to keep main's dev overlay working; whether that is the wanted trade-off is not decided here.

Tests

  • On this branch (main f9f3ec4c6 merged), Windows 11, Python 3.12, no GPU used: C++ only: left to this PR's CI (no local C++ build in this run).
  • Earlier merge: ctest 502 tests, submit_phases and dev_overlay pass; red: the test does not compile on main (kDefaultPeriodSeconds, kNsPerSecond, kMaxPeriodSeconds absent).
  • python -I scripts/check_no_game_data.py on every file this PR changes: clean.
  • CI on this PR covers the rest (C++ build and ctest, the full translator suite).

Depends on: none.

Needs a careful human read of the resolution and an independent verifier before merge (red/green on another machine).

AI-assisted (Claude Code, oreofr-agent).

🤖 Generated with Claude Code

Carries #2031 by @IlyassRS3, because it conflicts with `main` after #2566 and the reminder to merge `main` (https://github.com/ProjectLeonida/mandy/pull/2031#issuecomment-7232642471) got no answer within the delay of the carry rule. If the author comes back, this carry is dropped. Item: `RT-SUBMIT-PHASES-PERIOD-PARSE-AND-ZERO-OVERHEAD-SCOPE-CARRY` (claimed in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7280119323; original item `RT-SUBMIT-PHASES-PERIOD-PARSE-AND-ZERO-OVERHEAD-SCOPE`). ### What this branch is - The author's branch at `ed34b996c`, unchanged (no rebase, author commits kept). - A merge of `main` (from the carry preparation of 29/11) that resolves the conflict, then a merge of current `main` `f9f3ec4c6` (no new conflict). Both merge commits carry `Co-authored-by` the author. - Nothing else: the change itself is the original PR's; see #2031 for what and why, and the verifications posted there. ### What conflicted and how it was resolved - `runtime/src/submit_phases.h`: `main`'s `Scope` (nested phases, active phase) kept. The PR's skip now applies only when nobody reads the times: `timing_wanted()` is period 0 **and** `LEONIDA_DEV_OVERLAY` not 1, because `main`'s dev overlay reads these totals and the active phase. **Design choice for a human:** the PR's zero-overhead skip is narrowed to keep `main`'s dev overlay working; whether that is the wanted trade-off is not decided here. ### Tests - On this branch (`main` `f9f3ec4c6` merged), Windows 11, Python 3.12, no GPU used: C++ only: left to this PR's CI (no local C++ build in this run). - Earlier merge: `ctest` 502 tests, `submit_phases` and `dev_overlay` pass; red: the test does not compile on `main` (`kDefaultPeriodSeconds`, `kNsPerSecond`, `kMaxPeriodSeconds` absent). - `python -I scripts/check_no_game_data.py` on every file this PR changes: clean. - CI on this PR covers the rest (C++ build and `ctest`, the full translator suite). Depends on: none. **Needs a careful human read of the resolution and an independent verifier before merge** (red/green on another machine). AI-assisted (Claude Code, oreofr-agent). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-11-30 13:59:34 +00:00

Regression in the carry: frame and floor reports lose phase timings. The timing_wanted() gate considers the phase line and dev overlay. The frame and floor reports also read the phase counters and have a separate interval, LEONIDA_SUBMIT_FRAME_SECONDS, which defaults to 10 seconds.

MEASURED on b2914269 merged with main 20fe0c75 (tree 197476d4). The tested header and stock tests are byte-identical in the clean merge onto f44904d2. I ran the same synthetic probe under native Linux Clang 23.1.5 with ASan/UBSan and under Wine 11.22 with a Win64 clang-cl build. It opens a Submission with nested texture and replay scopes and advances the report deadline in the fixture to exercise the production emitters.

With LEONIDA_SUBMIT_PHASES_SECONDS=0 and the overlay unset, I tried both an unset frame interval (10 s) and LEONIDA_SUBMIT_FRAME_SECONDS=1. On both platforms and settings, main reported nonzero texture/replay times and a nonzero submission floor. The PR still emitted both reports and counted 2 submissions and 2 floor samples, with zero phase and floor times.

A local control that added || frame_period_ns() > 0 to timing_wanted() restored those times. In both the PR and control, scopes stayed untimed with all three consumers off, and timed with only the overlay or only the phase line enabled. The unmodified submit_phases and dev_overlay tests passed under Wine. A second agent checked the raw logs. CPU-only synthetic test, AI-assisted.

**Regression in the carry: frame and floor reports lose phase timings.** [The `timing_wanted()` gate](https://github.com/ProjectLeonida/mandy/blob/b29142696608894ac3f5ba4035a2b67566752829/runtime/src/submit_phases.h#L291-L306) considers the phase line and dev overlay. The frame and floor reports also read the phase counters and have a separate interval, `LEONIDA_SUBMIT_FRAME_SECONDS`, which defaults to 10 seconds. **MEASURED** on `b2914269` merged with `main` `20fe0c75` (tree `197476d4`). The tested header and stock tests are byte-identical in the clean merge onto `f44904d2`. I ran the same synthetic probe under native Linux Clang 23.1.5 with ASan/UBSan and under Wine 11.22 with a Win64 clang-cl build. It opens a `Submission` with nested texture and replay scopes and advances the report deadline in the fixture to exercise the production emitters. With `LEONIDA_SUBMIT_PHASES_SECONDS=0` and the overlay unset, I tried both an unset frame interval (10 s) and `LEONIDA_SUBMIT_FRAME_SECONDS=1`. On both platforms and settings, main reported nonzero texture/replay times and a nonzero submission floor. The PR still emitted both reports and counted 2 submissions and 2 floor samples, with zero phase and floor times. A local control that added `|| frame_period_ns() > 0` to `timing_wanted()` restored those times. In both the PR and control, scopes stayed untimed with all three consumers off, and timed with only the overlay or only the phase line enabled. The unmodified `submit_phases` and `dev_overlay` tests passed under Wine. A second agent checked the raw logs. CPU-only synthetic test, AI-assisted.
Kal0s-design commented 2026-11-30 14:18:14 +00:00

Independent Windows check of b29142696 on current main b17b22d33 (no conflict, tree ea277f812). Native Windows 11, MSVC 19.50 x64, built alone as its CMake target builds it (/Isrc), under AddressSanitizer with the debug CRT and checked iterators (/W4 /permissive- /utf-8 /Od /MDd /fsanitize=address).

  • Green: test/submit_phases_test.cpp: submit_phases_test: OK (0 failures), no ASan report.
  • No red run is possible: the test uses parse_period_ns and the k*PeriodSeconds constants this PR adds to submit_phases.h, so it doesn't build against main.
  • The only warnings are two C4996 getenv in submit_phases.h, which main has too (two of them there as well).

I didn't read the conflict resolution line by line.

GPUs tested: n/a (CPU unit test). AI-assisted: yes.

**Independent Windows check** of `b29142696` on current `main` `b17b22d33` (no conflict, tree `ea277f812`). Native Windows 11, MSVC 19.50 x64, built alone as its CMake target builds it (`/Isrc`), under AddressSanitizer with the debug CRT and checked iterators (`/W4 /permissive- /utf-8 /Od /MDd /fsanitize=address`). - Green: `test/submit_phases_test.cpp`: `submit_phases_test: OK (0 failures)`, no ASan report. - No red run is possible: the test uses `parse_period_ns` and the `k*PeriodSeconds` constants this PR adds to `submit_phases.h`, so it doesn't build against `main`. - The only warnings are two C4996 `getenv` in `submit_phases.h`, which `main` has too (two of them there as well). I didn't read the conflict resolution line by line. GPUs tested: n/a (CPU unit test). AI-assisted: yes.
KelboLive commented 2026-11-30 15:30:15 +00:00

Independent check on Windows (not the author), at b29142696.

  • Configured the branch's runtime and built submit_phases_test (MSVC 14.52.37025, Windows SDK 10.0.26100).
  • Ran it: submit_phases_test: OK (0 failures) — exit 0.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.

Based on f9f3ec4c6; a rebase on current main before merge would keep history linear.

AI-assisted: yes (opencode).

Independent check on Windows (not the author), at `b29142696`. - Configured the branch's `runtime` and built `submit_phases_test` (MSVC 14.52.37025, Windows SDK 10.0.26100). - Ran it: `submit_phases_test: OK (0 failures)` — exit 0. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. Based on `f9f3ec4c6`; a rebase on current `main` before merge would keep history linear. AI-assisted: yes (opencode).
OreoFR commented 2026-11-30 15:34:41 +00:00

c13dc82a5 fixes the regression @merzleckeier found: timing_wanted() now also counts the frame and floor lines (frame_period_ns() > 0, LEONIDA_SUBMIT_FRAME_SECONDS, 10 s by default) as a consumer of the phase times, which is the control from the report above.

  • New test test_timing_wanted_for_frame_lines in runtime/test/submit_phases_test.cpp: main() sets LEONIDA_SUBMIT_PHASES_SECONDS=0, unsets LEONIDA_SUBMIT_FRAME_SECONDS and LEONIDA_DEV_OVERLAY before anything reads them (timing_wanted() decides once per process), then checks that timing_wanted() is true and that a Scope is active.
  • MEASURED, macOS 27.2.1, Apple clang, -std=c++20 -Wall -Wextra -fsanitize=address,undefined: red (this PR's header before the fix + the new test): submit_phases_test: FAILED (2 failures), the two new checks; green: submit_phases_test: OK (0 failures), no sanitizer report, no warning.
  • MEASURED, a probe of timing_wanted() and Scope::active per process: all three consumers off (PHASES=0, FRAME=0, no overlay) → 0/0, so the zero-overhead scope this PR is for still holds; frame line only (default or FRAME=1) → 1/1; phase line only → 1/1; overlay only → 1/1.
  • Not run: MSVC (the test uses _putenv_s under _WIN32). Same owner as the carry: needs someone else's check.

AI-assisted: Claude Code

`c13dc82a5` fixes the regression @merzleckeier found: `timing_wanted()` now also counts the frame and floor lines (`frame_period_ns() > 0`, `LEONIDA_SUBMIT_FRAME_SECONDS`, 10 s by default) as a consumer of the phase times, which is the control from the report above. - New test `test_timing_wanted_for_frame_lines` in `runtime/test/submit_phases_test.cpp`: `main()` sets `LEONIDA_SUBMIT_PHASES_SECONDS=0`, unsets `LEONIDA_SUBMIT_FRAME_SECONDS` and `LEONIDA_DEV_OVERLAY` before anything reads them (`timing_wanted()` decides once per process), then checks that `timing_wanted()` is true and that a `Scope` is active. - MEASURED, macOS 27.2.1, Apple clang, `-std=c++20 -Wall -Wextra -fsanitize=address,undefined`: **red** (this PR's header before the fix + the new test): `submit_phases_test: FAILED (2 failures)`, the two new checks; **green**: `submit_phases_test: OK (0 failures)`, no sanitizer report, no warning. - MEASURED, a probe of `timing_wanted()` and `Scope::active` per process: all three consumers off (`PHASES=0`, `FRAME=0`, no overlay) → 0/0, so the zero-overhead scope this PR is for still holds; frame line only (default or `FRAME=1`) → 1/1; phase line only → 1/1; overlay only → 1/1. - Not run: MSVC (the test uses `_putenv_s` under `_WIN32`). Same owner as the carry: needs someone else's check. AI-assisted: Claude Code
MoonEyes commented 2026-11-30 15:50:15 +00:00

Verified by MoonEyes (another owner than OreoFR) on head c13dc82a5 merged with main be7690805: Windows 11, MSVC 2022 x64, RelWithDebInfo, ctest -R ^submit_phases$: 1/1 passed, with the new case for the frame lines that merzleckeier reported. Red on the old header of main is not possible here (the test uses names this pull request adds); the author measured red and green for that case on Mac. CPU unit test, no run of the title.

AI-assisted (Claude Code).

Verified by MoonEyes (another owner than OreoFR) on head `c13dc82a5` merged with `main` `be7690805`: Windows 11, MSVC 2022 x64, RelWithDebInfo, `ctest -R ^submit_phases$`: 1/1 passed, with the new case for the frame lines that merzleckeier reported. Red on the old header of `main` is not possible here (the test uses names this pull request adds); the author measured red and green for that case on Mac. CPU unit test, no run of the title. AI-assisted (Claude Code).
OreoFR commented 2026-11-30 16:30:15 +00:00

The windows job of run 46451903600 was cancelled by its 50-minute limit, not by a failure: the build took about 48 minutes (cold cache), ctest started at 16:25:58 and was at test 209 of 547 when time ran out. This PR's own test had already run there: 29/547 Test #29: submit_phases ... Passed. c08ececaf merges current main to run the CI again (no change to the PR's files; submit_phases_test OK on macOS under ASan/UBSan after the merge).

AI-assisted: Claude Code

The `windows` job of run 46451903600 was cancelled by its 50-minute limit, not by a failure: the build took about 48 minutes (cold cache), ctest started at 16:25:58 and was at test 209 of 547 when time ran out. This PR's own test had already run there: `29/547 Test #29: submit_phases ... Passed`. `c08ececaf` merges current `main` to run the CI again (no change to the PR's files; `submit_phases_test` OK on macOS under ASan/UBSan after the merge). AI-assisted: Claude Code
OreoFR commented 2026-11-30 16:33:55 +00:00

The new windows failure (run 46462604990, 1 minute) is the CI's cache, not this PR: sccache: error: Server startup failed: cache storage failed to read ... ServerBusy: Egress is over the account limit while compiling vulkan_aftermath.cpp and crt_timed_wait.cpp. It needs a rerun once the cache quota is back.

AI-assisted: Claude Code

The new `windows` failure (run 46462604990, 1 minute) is the CI's cache, not this PR: `sccache: error: Server startup failed: cache storage failed to read ... ServerBusy: Egress is over the account limit` while compiling `vulkan_aftermath.cpp` and `crt_timed_wait.cpp`. It needs a rerun once the cache quota is back. AI-assisted: Claude Code
MoonEyes commented 2026-11-30 17:14:36 +00:00

Verified again by MoonEyes (another owner than OreoFR) on head e957e20d6 merged with main 1d4949d58: Windows 11, MSVC 2022 x64, RelWithDebInfo, ctest -R ^submit_phases$: 1/1 passed. Same note as before on red. CPU unit test, no run of the title.

AI-assisted (Claude Code).

Verified again by MoonEyes (another owner than OreoFR) on head `e957e20d6` merged with `main` `1d4949d58`: Windows 11, MSVC 2022 x64, RelWithDebInfo, `ctest -R ^submit_phases$`: 1/1 passed. Same note as before on red. CPU unit test, no run of the title. AI-assisted (Claude Code).
MoonEyes commented 2026-11-30 17:15:32 +00:00

Merging. Head e957e20d6 merges cleanly with main cee1cb1d3 and does not force a rebase of #2566. Verified on this head on Windows 11 by another owner; merzleckeier's regression fixed. Merged by MoonEyes.

AI-assisted (Claude Code).

Merging. Head `e957e20d6` merges cleanly with `main` `cee1cb1d3` and does not force a rebase of #2566. Verified on this head on Windows 11 by another owner; merzleckeier's regression fixed. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.