Always write sample events in EventPipe based on sample frequency. #58720
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.
If no managed frames are located on stack, sample was dropped and not emitted into EventPipe by sample profiler. This cause issues in tooling that try to do thread time calculations based on sample, especially in cases where embedded threads returned to native code during several samples before calling back into runtime. In such scenarios the last sampled event would be prolonged, giving false information that that stack frame lasted much longer than it really did.
Always writing samples into EventPipe will also visualize time an attached thread spend outside of runtime, not running managed code.
Fix should open up for better visualization as described in dotnet/android#6243.
We can do similar fix to CoreCLR as well:
runtime/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp
Line 117 in db04259
but I'm splitting fixes into different PR's since MonoVM's embedding scenario makes this scenario much more likely to occur (already observed in different embedding scenarios) than CoreCLR.