Fix flaky CpuAndWallTimeWorker sampling test on macOS#5482
Fix flaky CpuAndWallTimeWorker sampling test on macOS#5482
Conversation
Root cause: The test sleeps for only 100ms and expects ≥5 samples at 100 samples/sec. On macOS-15 ARM64 + Ruby 3.0 CI runners, profiler startup overhead and thread scheduling variability reduce the effective sampling window, resulting in only 4 samples (just below the threshold). Increase sleep from 0.1s to 0.2s to provide more margin for sample collection, matching the duration used by similar tests in the same file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: c01965c | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-03-19 20:46:29 Comparing candidate commit c01965c in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 unstable metrics.
|
What does this PR do?
Fixes a flaky profiling test by increasing the sampling window from 100ms to 200ms.
Motivation:
The test
CpuAndWallTimeWorker#start when main thread is sleeping but a background thread is workingfailed onTest (macos-15, 3.0)in PR #5481 withsample_count: 4(threshold: 5). The profiler only managed 4trigger_sample_attemptsin the 100ms window due to startup overhead on macOS ARM64 + Ruby 3.0 runners.How I Reproduced the Issue
The CI failure on PR #5481 shows the test got exactly 4 samples in 100ms instead of the required 5. The stats (
trigger_sample_attempts=>4) confirm the profiler didn't even attempt enough samples — it's not a signal delivery issue, but insufficient time.Root Cause
The test sleeps for only 100ms and expects ≥5 samples at a target rate of 100 samples/sec. On macOS-15 ARM64 CI runners with Ruby 3.0, profiler startup overhead and thread scheduling variability reduce the effective sampling window below what's needed for 5 samples. The margin between expected (10 samples) and threshold (5) is too thin for this environment.
Fix
Increase sleep from 0.1s to 0.2s, matching the duration used by similar tests in the same file (lines 474 and 605). At 100 samples/sec, 200ms gives ~20 expected samples — well above the threshold of 5.
Change log entry
None.
How to test the change?
CI should pass on
Test (macos-15, 3.0)which was previously failing.