KEMBAR78
GetFolderPath call in Hosting negatively affects startup performance · Issue #47269 · dotnet/aspnetcore · GitHub
Skip to content

GetFolderPath call in Hosting negatively affects startup performance #47269

@eerhardt

Description

@eerhardt

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This GetFolderPath call costs about 8% of CPU samples during startup in the Stage 1 Native AOT application:

if (!OperatingSystem.IsWindows() || !string.Equals(cwd, System.Environment.GetFolderPath(System.Environment.SpecialFolder.System), StringComparison.OrdinalIgnoreCase))
.

It triggers loading shell32.dll and windows.storage.dll that we probably wouldn't need.

Expected Behavior

shell32.dll doesn't need to be loaded by default on an asp.net api app.

Steps To Reproduce

Run the BasicMinimalApi app and profile the startup logic.

Exceptions (if any)

No response

.NET Version

8.0

Anything else?

Note that this code was copied from Microsoft.Extensions.Hosting.HostApplicationBuilder. If we make a change here, we should make the same change in Extensions Hosting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions