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?
Fix 3 flaky tests that have surfaced this week:
Datadog::Profiling::Collectors::CpuAndWallTimeWorker ._native_allocation_count when CpuAndWallTimeWorker has been started when allocation profiling is enabled returns the number of allocations between two calls of the method
https://app.circleci.com/pipelines/github/DataDog/dd-trace-rb/14119/workflows/cbefa69c-c16e-41fd-a601-2e951a5264ab/jobs/525211
expect(after_allocations - before_allocations).to be 100 | expected #<Integer:201> => 100 | got #<Integer:215> => 107
TL;DR: Rare GC occurrence in the middle of the test would count extra array allocations due to execution of finalizer functions with complex arguments (
*rest
) which are expected to come from usage ofTempfile
in previous tests in the run.C backtrace of Array-typed allocation samples during allocation of 100 Objects
Datadog::Profiling::Collectors::CpuAndWallTimeWorker #stats_reset_not_thread_safe returns accumulated stats and resets them back to 0
Datadog::Profiling::Collectors::CpuAndWallTimeWorker #start when heap profiling is enabled records live heap objects
expect(relevant_sample.values[:'heap-live-samples']).to eq test_num_allocated_object | expected: 123 | got: 120
gc gen age
and thus being aggregated in multiple samples rather than the expected individual one.Motivation:
Less flakes!
Additional Notes:
How to test the change?
These bugs were reproduced and fixed through thousands of local executions of the
cpu_and_wall_time_worker_spec.rb
. We haven't hit failures after fixing them but you're welcome to give it a try!For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance
.Unsure? Have a question? Request a review!