Skip to content

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

Open
@jkotas

Description

@jkotas

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions