Repository navigation
Harden timing-dependent Studio backend tests (nvidia-smi cache, cold /api/health) - #12275
Conversation
…e gpu_query tests Four tests started a thread, slept a fixed 0.15 to 0.5 s, then changed the fake's state, assuming the older child had already read it. On a loaded runner the child can start later and read the state meant for the next reading (seen as test_a_child_started_before_an_invalidation_is_not_joined reading 64 MiB instead of 180000). The fake logs each call after reading its state, so wait for that line.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…eadline test A shared CI runner stalled one cold call to 2.06s against the desktop probe's 2.0s timeout (#11929's Python 3.13 shard); the same call takes 1.02-1.07s idle and on a contended core. A fresh process measures again and the lower reading is asserted, so a cold-path regression (checked with a 1.2s first-call delay) still fails while a one-off stall does not. The 2.0s bound itself is unchanged.
|
@codex review |
|
@codex security review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Problem
studio/backend/tests/test_gpu_query_cache.py::test_a_child_started_before_an_invalidation_is_not_joined(added in #11995) failed on a CI run of an unrelated PR (Python 3.13, a-k shard):It passes on reruns and locally, so it is timing dependent.
Cause
The test starts a thread that spawns the fake
nvidia-smi, sleeps a fixed 0.15 s, then sets the free memory the NEXT reading should see. It assumes the first child has already read its state by then. On a loaded runner the Python child can start later than that, reads the new state, and returns 64 MiB. The caching code behaves correctly; the test raced.Three more tests from #11995 have the same shape (start a thread, fixed sleep, change the fake's state):
test_a_static_read_after_redetection_does_not_join_an_older_child,test_an_older_answer_does_not_overwrite_a_newer_empty_oneandtest_a_fit_check_does_not_join_an_older_child.Fix
The fake writes its call line only after reading its state, so
FakeSmi.wait_for_call(needle, count)polls for that line (30 s bound, assertion on timeout), and the four tests wait for one more matching call than before the thread started instead of sleeping. Test-only change.Evidence
The four tests, pinned to one CPU core shared with 4 busy loops (so child start-up is slow, like a loaded runner), 3 runs each:
Also: the cold
/api/healthlauncher-deadline teststudio/backend/tests/test_health_answers_within_probe_budget.py::test_a_cold_health_call_answers_inside_the_launcher_deadlinefailed once on #11929's Python 3.13 shard:The cold path is the 1.0 s detection budget wait plus one threadpool hop, and it measures 1.02 to 1.07 s both idle and on a core shared with busy loops, so that run was a one-off stall of about a second on the runner. The 2.0 s bound is the launcher's real timeout (read from the Rust client) and stays as is, as #9724 intended. If the first cold measurement misses it, a fresh process measures once more and the lower reading is asserted:
/api/healthcall