Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 7, 2021

Backport of #58720 to release/6.0

/cc @lateralusX

Customer Impact

Observed in embedding scenarios using diagnostic tools like speedscope, dotnet/android#6243 on nettrace files generated on Android. These tools uses EventPipe sample profiler event to apply thread time. Since its a sample profiler, that is error prone, but since we won't write samples based on frequency in case where threads don't have any managed frames on stack (could happen on embedding thread), tools will incorrectly prolong thread time for last sample including managed frames. Fix will make sure samples are still written into EventPipe when we are in unmanaged code without managed frames on stack, assisting tooling's thread time heuristics, more accurately represent time for last sampled managed callstack. NOTE, this scenario is highly workload and implementation dependent, in cases where attached runtime threads stays in runtime (managed or unmanaged code), there will always be managed frames on the stack, this issue only happens if an attached thread returns back to native code.

Testing

Manual testing validating that tools better represent thread times in embedding scenarios.

Risk

Low, samples with 0 length callstack are handled by both Perfview, Speedscope and VS. Amount of samples in unmanaged code will increase in calltrees when this scenarios happens, mainly an issue in Perfview, but can be excluded from analysis if not needed and these events will only be included in embedding scenarios (and attached threads returns back out to native code).

If no managed frames (including helper frames) are located on stack,
sample was dropped and not emitted into EventPipe. 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 stackframe 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.
Only include external samples still on top fram (no callstack) or
managed/external samples includig a callstack.
@Anipik Anipik merged commit ef046aa into release/6.0 Sep 8, 2021
@akoeplinger akoeplinger deleted the backport/pr-58720-to-release/6.0 branch September 9, 2021 11:25
@ghost ghost locked as resolved and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants