dotnet / dotnet/aspnetcore

Reduce the size of the Developer Exception Page in NativeAOT

Open
#46,969 3 comments 1 reaction 0 assignees View on GitHub
area-middleware feature-diagnostics investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

In investigating size of NativeAOT apps, one area of additional size is app.UseDeveloperExceptionPage().

When comparing the win-x64 sizes before and after adding the `app.UseDeveloperExceptionPage()` line, I see the following sizes:

```
8.99 MB (9,428,480 bytes) - AddRoutingCore()+app.UseRouting()+UseEndpoints+MapGet
9.56 MB (10,031,616 bytes) - AddRoutingCore()+app.UseRouting()+UseEndpoints+MapGet+app.UseDeveloperExceptionPage()
```

This means adding `app.UseDeveloperExceptionPage()` adds about 550 KB of app size.

We should investigate if there is a way to make this feature smaller. One way to make it smaller is https://github.com/dotnet/aspnetcore/issues/46915. There may be other optimization we could make to reduce app size. For example, maybe eliminating `System.Linq` usages. Another option is removing `UseDeveloperExceptionPage()` from CreateSlimBuilder and make it optional for the app to add it (possibly putting it into the `dotnet new api` template).

cc @DamianEdwards @halter73 @amcasey @captainsafia

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported NativeAOT size comparison for app.UseDeveloperExceptionPage() and inspect the middleware and CreateSlimBuilder entry points. Review the possible System.Linq reduction, the related issue 46915, and the dotnet new api template; done means an agreed, measured reduction in app size or a decided change to how the feature is included.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.