[PROF-10422] Fix flaky GVL profiling integration spec #3936
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.
What does this PR do?
This PR fixes a flaky specs seen in
https://app.circleci.com/pipelines/github/DataDog/dd-trace-rb/16487/workflows/df69cfde-1fd5-40dc-bff6-ac8a9d0bc713/jobs/593534 :
I was able to reproduce this failure on my local machine in around 1 in 20 runs.
This flakiness is caused by the profiler starting after a Waiting for GVL already started, and thus the profiler does not see it and still categorizes that period as "unknown"; thus our tight assertion is blown.
It's not a coincidence that the difference between 492191168 and 402832467 is within ~100ms: that's the scheduler latency caused by the background thread that's burning CPU.
To fix this issue, we subtract the duration of this initial period from the
total_time
: this is the period we care for.To avoid us accidentally passing this test by having no Waiting for GVL, I've added an additional assertion for a sane
total_value
.Motivation:
Make sure the profiler has zero flaky specs.
Additional Notes:
This PR is on top of #3934 for easier testing, but it's otherwise independent of it.
How to test the change?
Validate that CI is green and that the flaky test does not show up again.