Repository navigation
StopWatch_test: consume CPU time instead of waiting wall time - #10276
Merged
Merged
Conversation
The stop() section busy-waited a fixed wall time (0.2 s, then 0.1 s) and then required the process to have received at least half of it as CPU time. CI runs four tests in parallel (ctest jobs = 4), on the 3-core macOS runner among others, so the test sometimes got less than half a core and failed in lines 144, 152 and 179 (seen on #9966). consumeCPU() busy-waits until a StopWatch probe has seen the requested CPU time, so the CPU time assertions hold however busy the machine is; only the wall time needed grows with the load. Wall-time checks are now relative to the CPU time plus a coarse upper bound, and lower bounds allow for the coarse CPU clock ticks (10 ms on POSIX, ~15.6 ms on Windows). A 30 s wall-time cap keeps a broken CPU clock from hanging the test. Pinned to one core together with 3 (7) busy loops, the old test failed 10/10 times; the new one passed 10/10 (1.4 s / 2.8 s per run). Unloaded it passed 50/50 at 0.37 s per run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015br53P8rFQMnErUa4SiMSX
Contributor
|
Warning Review limit reachedNext included review available in 38 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
StopWatch_testfails now and then in CI, most recently on the macOS job of #9966 (line 179; it passed on a re-run).Cause. The
stop()section busy-waits a fixed wall time (0.2 s, then 0.1 s) and then requires the process to have received at least half of it as CPU time, i.e. at least half a core. CI runs four tests in parallel (ctestjobs = 4 in the CI test presets), on the 3-core macOS runner among others, so the test sometimes gets less than that. The affected assertions are lines 144, 152 and 179; the tight wall-time upper bounds (< 0.3 s,< 3 × t_wait) carried the same risk.Change (test only,
StopWatch_test.cpp).consumeCPU()busy-waits until aStopWatchprobe has seen the requested CPU time. The watches under test read the same process counter and were started before the probe, so the CPU-time lower bounds now hold however busy the machine is; only the wall time needed grows with the load.< 60 sbound that still catches unit errors.resume()accumulates both intervals) and the existing Windows workarounds are unchanged.std::clock()was not used as an independent reference because on Windows it measures wall time, not CPU time.Validation (Linux, 4 cores). Test and busy loops pinned to the same core with
taskset -c 0:Under load the new test measured 0.18 s user and 0.03 s system time for the 0.2 s interval.
Checklist
StopWatch_testas above)How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI builds🤖 Generated with Claude Code
https://claude.ai/code/session_015br53P8rFQMnErUa4SiMSX
Generated by Claude Code