Skip to content
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

Ready2Run images are still loaded when COR_PRF_DISABLE_ALL_NGEN_IMAGES is set #8633

Closed
davmason opened this issue Jul 25, 2017 · 7 comments
Closed

Comments

@davmason
Copy link
Member

From the profiler's point of view, it does not know about the differences between R2R and NGEN. There is a profiler flag to set COR_PRF_DISABLE_ALL_NGEN_IMAGES, to ensure that no pre-generated code is loaded.

However, this flag does not prevent the loading of R2R images. This is an issue for the profiler because pre-generated code cannot be instrumented, such as enter/leave callbacks, does not have jit events, etc.

I wrote a sample profiler and tested it without COR_PRF_DISABLE_ALL_NGEN_IMAGES, with it, and without it plus COMPLUS_ReadyToRun=0. Here are the results. Note that "loaded as NGEN" just means loaded as a pre-compiled library, they are all R2R except for System.Private.CoreLib

****************** Testing with profiler allowing NGEN **********************
Profiler initialized.
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Private.CoreLib.ni.dll" loaded as NGEN
Module "D:\Ready2RunProfilerRepro\Ready2RunTest.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Runtime.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\mscorlib.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Console.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.IO.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Threading.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.IO.FileSystem.Primitives.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Text.Encoding.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Text.Encoding.Extensions.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Threading.Tasks.dll" loaded as NGEN
Hello World!


****************** Testing with profiler COR_PRF_DISABLE_ALL_NGEN_IMAGES set **********************
Profiler forbidding NGEN
Profiler initialized.
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Private.CoreLib.ni.dll" loaded as IL
Module "D:\Ready2RunProfilerRepro\Ready2RunTest.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Runtime.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\mscorlib.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Console.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.IO.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Threading.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.IO.FileSystem.Primitives.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Text.Encoding.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Text.Encoding.Extensions.dll" loaded as NGEN
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Threading.Tasks.dll" loaded as NGEN
Hello World!


****************** Testing with COMPLUS_ReadyToRun=0 **********************
Profiler initialized.
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Private.CoreLib.ni.dll" loaded as NGEN
Module "D:\Ready2RunProfilerRepro\Ready2RunTest.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Runtime.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\mscorlib.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Console.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.IO.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Threading.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.IO.FileSystem.Primitives.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Text.Encoding.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Text.Encoding.Extensions.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Threading.Tasks.dll" loaded as IL
Module "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Runtime.InteropServices.dll" loaded as IL
Hello World!
@davmason
Copy link
Member Author

Fixed in dotnet/coreclr#13043

@mmayr-at
Copy link

mmayr-at commented Aug 3, 2017

I just ran into this issue with the latest .NET Core 2.0.0 Preview. I tried an ASP.NET Core application and was not able to instrument code into the Micrsoft.AspNetCore.Http.Abstractions.dll assembly. Then I found out that a this was a r2r image.

I see that this is planned for Milestone 2.1.0, but I would like to see this included in the 2.0.0 release. Otherwise we must use a workaround and set the ReadyToRun option for every process we would like to profile.

/CC @jkotas @noahfalk

@davmason
Copy link
Member Author

davmason commented Aug 3, 2017

@mmayr-at It is unfortunately too late for 2.0, it has already locked down.

For what it's worth, this fix means that when a profiler is attached and requests that NGEN images are not loaded, it is the same impact as setting COMPLUS_ReadyToRun=0. You don't gain anything with this fix, other than not having to set the extra environment variable.

@mmayr-at
Copy link

mmayr-at commented Aug 4, 2017

This is bad news for us, but thanks for that information. I know that the workaround is quite easy, but we have to deploy it to production/testing environments and have to consider it in everyday development tasks.

@jkotas
Copy link
Member

jkotas commented Aug 4, 2017

@davmason We should include this fix in the first 2.0 servicing update (2.0.1).

@mmayr-at
Copy link

mmayr-at commented Aug 7, 2017

@jkotas This is definitely better than waiting for the 2.1.0 release, thx.

@danmoseley
Copy link
Member

dotnet/coreclr#13349

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants