Skip to content

Conversation

@davmason
Copy link
Contributor

We found out recently (#59741) that we have no coverage for whether the runtime respects the profiler's request to prevent or allow inlining. This adds some basic tests

@davmason davmason added this to the 7.0.0 milestone Oct 10, 2021
@davmason davmason requested a review from a team October 10, 2021 01:05
@davmason davmason self-assigned this Oct 10, 2021
@ghost
Copy link

ghost commented Oct 10, 2021

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

Issue Details

We found out recently (#59741) that we have no coverage for whether the runtime respects the profiler's request to prevent or allow inlining. This adds some basic tests

Author: davmason
Assignees: davmason
Labels:

area-Diagnostics-coreclr

Milestone: 7.0.0

@davmason
Copy link
Contributor Author

@noahfalk @josalem @hoyosjs does anybody have a minute to look at this?

Copy link
Member

@tommcdon tommcdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor comment for your review

Console.WriteLine($"Inlining, x={x}");
}

[MethodImpl(MethodImplOptions.NoInlining)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor Nit: Do we mean to block inlining via attribute on this method? It seems we want to verify that the profiler is making the decision to block inlining for this function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the test I think the only method where David intended to modify the inlining behavior from the profiler is "Inlinee". For all other methods we are just ensuring they don't unintentionally get inlined so that the test will get enter/exit callbacks for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, what Noah said 😄. I should have called this method "Inliner" and not "Inlining". I think it's actually worth updating for clarity

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Are you able to run this test against any .NET 6 build without your recent fixes and confirm the test fails?

@davmason
Copy link
Contributor Author

Are you able to run this test against any .NET 6 build without your recent fixes and confirm the test fails?

I can now confirm that it fails when targeting 6.0-rc1

BEGIN EXECUTION
 "C:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\\corerun.exe" -p "System.Reflection.Metadata.MetadataUpdater.IsSupported=false" inlining.dll
Profiler path: C:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\profiler\unittest\inlining\Profiler.dll
Disabling tiered compilation, jitstress, and minopts.
Profiler.dll!DllGetClassObject
Profiler.dll!Profiler::Initialize
Inlining, x=604021970
BlockInlining, x=159477398
Saw Inlinee as a real method call instead of inlined.
NoResponse, x=1597929155
Profiler.dll!Profiler::Shutdown
TEST FAILED _failures=1_sawInlineeCall=1

Test failed: Profiler tests are expected to contain the text 'PROFILER TEST PASSES' in the console output of the profilee app to indicate a passing test. Usually it is printed from the Shutdown() method of the profiler implementation. This text was not found in the output above.
Unhandled exception. System.Exception: Profiler tests are expected to contain the text 'PROFILER TEST PASSES' in the console output of the profilee app to indicate a passing test. Usually it is printed from the Shutdown() method of the profiler implementation. This text was not found in the output above.
   at Profiler.Tests.ProfilerTestRunner.FailFastWithMessage(String error) in C:\git\runtime\src\tests\profiler\common\ProfilerTestRunner.cs:line 190
   at Profiler.Tests.ProfilerTestRunner.Run(String profileePath, String testName, Guid profilerClsid, String profileeArguments, ProfileeOptions profileeOptions, Dictionary`2 envVars, String reverseServerName, Boolean loadAsNotification, Int32 notificationCopies)
   at Profiler.Tests.InliningTest.Main(String[] args) in C:\git\runtime\src\tests\profiler\unittest\inlining.cs:line 60
Expected: 100
Actual: -532462766

@davmason davmason merged commit aea5cb9 into dotnet:main Oct 21, 2021
@davmason davmason deleted the inlining_test branch October 21, 2021 09:27
@BruceForstall
Copy link
Contributor

@davmason I think this change is causing my PR to fail in the GCC build:

[ 87%] Linking CXX shared library libDelegateTestNative.so
/__w/1/s/src/tests/profiler/native/eltprofiler/slowpatheltprofiler.cpp:30:82: error: ‘visibility’ attribute ignored [-Werror=attributes]
   30 | PROFILER_STUB EnterStub(FunctionIDOrClientID functionId, COR_PRF_ELT_INFO eltInfo)
      |                                                                                  ^
/__w/1/s/src/tests/profiler/native/eltprofiler/slowpatheltprofiler.cpp:37:82: error: ‘visibility’ attribute ignored [-Werror=attributes]
   37 | PROFILER_STUB LeaveStub(FunctionIDOrClientID functionId, COR_PRF_ELT_INFO eltInfo)
      |                                                                                  ^
/__w/1/s/src/tests/profiler/native/eltprofiler/slowpatheltprofiler.cpp:44:85: error: ‘visibility’ attribute ignored [-Werror=attributes]
   44 | PROFILER_STUB TailcallStub(FunctionIDOrClientID functionId, COR_PRF_ELT_INFO eltInfo)
      |                                                                                     ^
[ 88%] Linking CXX shared library native_i7c/native_i7c.so
[ 88%] Built target DelegateTestNative

https://dev.azure.com/dnceng/public/_build/results?buildId=1434508&view=logs&jobId=43e4a348-e016-5d2a-a84b-7c597b487768&j=43e4a348-e016-5d2a-a84b-7c597b487768&t=0427443e-d386-5ea1-3848-e44c274b3f54

@davmason
Copy link
Contributor Author

@BruceForstall interesting, do you know why that leg didn't run on this PR? It looks like it should be an easy fix, I'm taking a look

@BruceForstall
Copy link
Contributor

Good question; I don't know.

I know @mangod9 (and I) encountered this problem recently. There was some issue with the version of gcc on some machines differing from others (?). @mangod9 Any info here?

@am11
Copy link
Member

am11 commented Oct 21, 2021

do you know why that leg didn't run on this PR? It looks like it should be an easy fix, I'm taking a look

The GCC leg was skipped in this PR because it is currently only triggered when src/coreclr has changed. Since src/tests and src/native also takes part in what gcc leg builds, we should adjust this condition:

eq(dependencies.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'], true),

to include:

          eq(dependencies.evaluate_paths.outputs['SetPathVars_runtimetests.containsChange'], true),

@mangod9
Copy link
Member

mangod9 commented Oct 21, 2021

The issue I ran into was where different CI machines had either gcc version 9 or 11. A particular codegen change was failing only on 11, so that can cause discrepancy in job failures. Dont think we looked into it further to determine why the versions are different.

@am11
Copy link
Member

am11 commented Oct 21, 2021

It was because that other PR was sitting there for over a month and merged without re-running the CI, and during that time gcc leg was updated from v9 to v11.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 21, 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.

6 participants