Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

josalem
Copy link
Contributor

@josalem josalem commented Oct 5, 2021

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
Copy link

ghost commented Oct 5, 2021

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
Copy link
Contributor Author

josalem commented Oct 5, 2021

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);
    }
}

@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