Skip to content

Correctly Save GC Mode on Suspension on Windows for SampleProfiler - #59974

Merged
josalem merged 1 commit into
dotnet:mainfrom
josalem:dev/josalem/fix-windows-unmanaged-code-time
Oct 7, 2021
Merged

josalem merged 1 commit into
dotnet:mainfrom
josalem:dev/josalem/fix-windows-unmanaged-code-time

Conversation

@josalem

@josalem josalem commented Oct 5, 2021

Copy link
Copy Markdown
Contributor

Fixes #45179

Move SaveGCModeOnSuspension to shared location rather than Unix only code path.

Before this change (as described in #45179), all events from the SampleProfiler on Windows would be marked as UNMANAGED_CODE_TIME samples. This was intended to only be the case for when a sample was collected while native code was on the stack.

This should make samples show up correctly in PerfView.

CC @tommcdon @noahfalk @brianrob

shared location rather than Unix only
@josalem josalem added this to the 7.0.0 milestone Oct 5, 2021
@josalem
josalem requested a review from a team October 5, 2021 00:19
@josalem josalem self-assigned this Oct 5, 2021
@ghost

ghost commented Oct 5, 2021

Copy link
Copy Markdown

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #45179

Move SaveGCModeOnSuspension to shared location rather than Unix only code path.

Before this change (as described in #45179), all events from the SampleProfiler on Windows would be marked as UNMANAGED_CODE_TIME samples. This was intended to only be the case for when a sample was collected while native code was on the stack.

This should make samples show up correctly in PerfView.

CC @tommcdon @noahfalk @brianrob

Author: josalem
Assignees: josalem
Labels:

area-Diagnostics-coreclr

Milestone: 7.0.0

@josalem

josalem commented Oct 5, 2021

Copy link
Copy Markdown
Contributor Author

Sample of the fixed behavior (left is before, right is after):

image

The code traced:

using System;
using System.Threading;
using System.Runtime.CompilerServices;

[MethodImpl(MethodImplOptions.NoInlining)]
int Foo(int bar) => bar + 1;

Console.WriteLine($"PID: {System.Diagnostics.Process.GetCurrentProcess().Id}");


while (true)
{
	// Should split unmanaged and managed suspensions about 50/50
    int i = 0;
    Thread.Sleep(TimeSpan.FromSeconds(1));
    DateTime then = DateTime.Now;
    while (DateTime.Now - then < TimeSpan.FromSeconds(1))
    {
        i = Foo(i);
    }
}

Comment thread src/coreclr/vm/threadsuspend.cpp Resolved
@josalem
josalem merged commit e98d71d into dotnet:main Oct 7, 2021
@josalem
josalem deleted the dev/josalem/fix-windows-unmanaged-code-time branch October 7, 2021 20:42
@ghost ghost locked as resolved and limited conversation to collaborators Nov 7, 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.

SampleProfiler incorrectly marks all samples as external code on Windows

4 participants