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

Assembly loader event tracing is very expensive (10x application slowdown) #78539

Open
jkotas opened this issue Nov 18, 2022 · 5 comments
Open

Comments

@jkotas
Copy link
Member

jkotas commented Nov 18, 2022

Repro

  1. dotnet new console in .NET 7 SDK, copy&paste the following program (repro extracted from actual app where the issue was observed)
using System.Diagnostics;

var sw = new Stopwatch();
for (;;)
{
    sw.Restart();
    for (int i = 0; i < 100000; i++) Type.GetType("System.String, System.Runtime");
    Console.WriteLine(sw.ElapsedMilliseconds);
}
  1. dotnet run
  2. Download latest perfview and start a global collection session with default settings (Select "Collect / Collect" from menu and press "Start Collection" button)

Actual result

Program runs more than 10x slower when the perfview collection session is active

Expected result

Default perfview collection settings should not slow down the program by more than 10%


The problem is caused by very slow assembly loader tracing. The fix should be to either make assembly loader tracing a lot faster and lighter weight for cases like this one and/or assembly loader tracing should not be enabled for default (perfview) event collection settings.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 18, 2022
@ghost
Copy link

ghost commented Nov 18, 2022

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Repro

  1. dotnet new console in .NET 7 SDK, copy&paste the following program (repro extracted from actual app where the issue was observed)
using System.Diagnostics;

var sw = new Stopwatch();
for (;;)
{
    sw.Restart();
    for (int i = 0; i < 100000; i++) Type.GetType("System.String, System.Runtime");
    Console.WriteLine(sw.ElapsedMilliseconds);
}
  1. dotnet run
  2. Download latest perfview and start a global collection session with default settings (Select "Collect / Collect" from menu and press "Start Collection" button)

Actual result

Program runs more than 10x slower when the perfview collection session is active

Expected result

Default perfview collection settings should not slow down the program by more than 10%


The problem is caused by very slow assembly loader tracing. The fix should be to either make assembly loader tracing a lot faster and lighter weight for cases like this one and/or assembly loader tracing should not be enabled for default (perfview) event collection settings.

Author: jkotas
Assignees: -
Labels:

area-AssemblyLoader-coreclr, untriaged

Milestone: -

@vitek-karas
Copy link
Member

I don't think detailed assembly load tracing should be enabled by default - it was not designed for that case. We specifically "Didn't care much" about perf since the goal was to provide on demand diagnostic tool.

@elinor-fung could you please look into disabling this as part of the default collection?

@elinor-fung
Copy link
Member

Agreed - it is intended for targeted assembly loading investigation and should not be enabled by default.

I'll look at updating perfview / TraceEvent defaults.

@elinor-fung
Copy link
Member

It looks like some of the VS tools also enable it - I'll get in contact for those as well.

@agocke agocke added this to the 8.0.0 milestone Apr 3, 2023
@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Apr 3, 2023
@agocke agocke added this to AppModel Jul 10, 2023
@agocke agocke modified the milestones: 8.0.0, Future Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants