[PROF-5942] Disallow sampling ractors in profiler #2357
Merged
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 builds on top of #2350 and changes the
Collectors::CpuAndWallTimeWorker
to never trigger sampling if any of its methods get called from outside the main ractor.This means that the profiler will not have visibility beyond the main ractor. Building support for that will come later, as we'll need to deal with the complexity of the profiler potentially being called from multiple ractors.
Motivation:
We don't yet support Ractors, but on an application using Ractors the profiler should not fail or misbehave. The expected behavior is that it just won't profile Ractors beyond the main one.
Additional Notes:
(Nothing)
How to test the change?:
I've included partial coverage, but testing the GC-related behavior was harder than I expected (also because of #2354), so for now I didn't add it.
To test this feature, you can enable profiling on a Ruby app using ractors and confirm that no samples appear from Ractors, but otherwise profiling works correctly (for threads in the main Ractor).
Here's a test app I've been using: