[PR #1237] frame_pacer: cancel a wait that spans suspend and re-registration #1269

Open
opened 2026-11-26 20:20:40 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1237
Author: @titoreinaldo
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: contrib/r2-pacer


📝 Commits (1)

  • 9a5ba38 frame_pacer: cancel waits that span suspend and re-registration

📊 Changes

2 files changed (+43 additions, -1 deletions)

View changed files

📝 runtime/src/frame_pacer.h (+5 -1)
📝 runtime/test/frame_pacer_test.cpp (+38 -0)

📄 Description

Claimed in the coordination issue as: RT-PACER-SUSPEND-EPOCH
Claim in #14

What and why

A wait could enter before suspend, wake after resume and re-registration, then consume the first tick of the new registration. A pre-suspend origin wait could even issue the resumed frame’s token. The pacer now records each suspend under its existing mutex. When a waiter regains the lock it can tell that its registration ended, even if the new one is already armed.

The regression drives that ordering through the existing injected clock. It checks origin, vblank and flip events, verifies the old wait returns invalid_state without changing the caller’s token, and verifies a fresh wait can still take the first resumed tick. This concerns the project’s modeled pacing contract. #1042 touches the same header for a different wakeup case. The two commits merge cleanly.

Tested

  • Built and ran the existing native frame_pacer_test first. It passed. Adding the new ordering against the pre-fix header failed at the expected old-wait assertion.
  • After the fix, the complete standalone test passed eight consecutive times on Windows. The registered Release CMake target also passed ten consecutive runs with ctest --test-dir <build> -R frame_pacer --repeat until-fail:10 --output-on-failure.
  • On the shared base 58be9cdf, 6,168 translator tests in 470 files had zero failing files. Verified a clean merge with main at 705ea091 and the head of #1042.

GPUs tested: CPU-only frame pacing, Windows 11 Pro 26H2 build 26300.9974, LLVM-MinGW 23.1.6.

AI-assisted: yes, OpenAI Codex. Synthetic clock and inputs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1237 **Author:** [@titoreinaldo](https://github.com/titoreinaldo) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `contrib/r2-pacer` --- ### 📝 Commits (1) - [`9a5ba38`](https://github.com/ubiquitarianism/leonida/commit/9a5ba38d88b0fa349abec79df46c0a70b4a5fc4c) frame_pacer: cancel waits that span suspend and re-registration ### 📊 Changes **2 files changed** (+43 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/frame_pacer.h` (+5 -1) 📝 `runtime/test/frame_pacer_test.cpp` (+38 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-PACER-SUSPEND-EPOCH [Claim in #14](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143476751) ### What and why A wait could enter before suspend, wake after resume and re-registration, then consume the first tick of the new registration. A pre-suspend origin wait could even issue the resumed frame’s token. The pacer now records each suspend under its existing mutex. When a waiter regains the lock it can tell that its registration ended, even if the new one is already armed. The regression drives that ordering through the existing injected clock. It checks origin, vblank and flip events, verifies the old wait returns `invalid_state` without changing the caller’s token, and verifies a fresh wait can still take the first resumed tick. This concerns the project’s modeled pacing contract. #1042 touches the same header for a different wakeup case. The two commits merge cleanly. ### Tested - Built and ran the existing native `frame_pacer_test` first. It passed. Adding the new ordering against the pre-fix header failed at the expected old-wait assertion. - After the fix, the complete standalone test passed eight consecutive times on Windows. The registered Release CMake target also passed ten consecutive runs with `ctest --test-dir <build> -R frame_pacer --repeat until-fail:10 --output-on-failure`. - On the shared base `58be9cdf`, 6,168 translator tests in 470 files had zero failing files. Verified a clean merge with `main` at `705ea091` and the head of #1042. GPUs tested: CPU-only frame pacing, Windows 11 Pro 26H2 build 26300.9974, LLVM-MinGW 23.1.6. AI-assisted: yes, OpenAI Codex. Synthetic clock and inputs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
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
starred/leonida#1269
No description provided.