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

.NET Alloc profiler activation on .NET (Core) #1955

Open
ocoanet opened this issue Dec 1, 2023 · 2 comments
Open

.NET Alloc profiler activation on .NET (Core) #1955

ocoanet opened this issue Dec 1, 2023 · 2 comments

Comments

@ocoanet
Copy link
Contributor

ocoanet commented Dec 1, 2023

The .NET Alloc option requires the activation of a specific CLR profiler. The activation is implemented in PerfView by configuring HKLM\Software\Microsoft\.NETFramework\COR* registry keys. It does not seem to have any effect on my net7.0 application:

Action Target Framework Has ETWClrProfiler events
Run/Collection net461 Yes
Run/Collection net7.0 No
Run/Collection net7.0 + manual profiler activation using environment variables Yes

Is this behavior a configuration issue on my side?

I could not find any documented way to activate profilers from registry keys for the .NET (Core) runtime, so maybe it is a known and expected behavior.

However, if the profiler cannot be activated using registry keys, I suppose that PerfView should be improved:

  • By explicitly documenting the behavior ("Collect" cannot enable the profiler and it must be manually enabled).
  • By automatically configuring the expected environment variable when collecting with the "Run" action.

It can eventually create a PR for the last point.

@brianrob
Copy link
Member

brianrob commented Dec 1, 2023

I don't believe that the registry is supported for configuring the profiler API for .NET Core. @davmason can you please confirm.

At the same time, you should be able to capture the unsampled allocation events directly in PerfView without using the profiler API at all. This is done by specifying /ClrEvents:Default+GCAllObjectAllocation.

@ocoanet
Copy link
Contributor Author

ocoanet commented Dec 2, 2023

I did a few experiments with GCAllObjectAllocation and it seems to generate unsampled Microsoft-Windows-DotNETRuntime/GC/SampledObjectAllocation events. So, indeed, it is a good option to capture allocations for .NET (Core) programs.

But my main issue is that many collection UI options are linked to the CLR profiler. This fact is not clearly documented and these options have no effect on .NET (Core) programs unless the profiler is manually enabled.

I think that both the collection UI and the documentation (PerfView Help) should be improved to make more explicit the behaviors. Also, it would be nice to have an option to enable GCAllObjectAllocation.

I clearly lake experience on the subject to describe a complete solution. I can only make a few suggestions:

  1. Either move all CLR-profiler-related options to a specific section, or add a "Profiler" prefix to the options labels.
  2. Add a CLR profiler documentation entry to explain its role, usage and activation.
  3. Add an option to automatically enable the profiler in the "Run" collection.
  4. Rename "ETW .NET Alloc" to "CLR SampAlloc".
  5. Add an option "CLR Alloc" (related to GCAllObjectAllocation).

I can probably help on these tasks if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants