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

ASP.NET Core 8 container images should use new Dynamic Adaptive GC mode #4683

Closed
DamianEdwards opened this issue Jun 20, 2023 · 14 comments
Closed

Comments

@DamianEdwards
Copy link
Member

DamianEdwards commented Jun 20, 2023

.NET 8 introduces a new variation of Server GC called "Dynamic Adaptive GC" that can be opted-into. Its intent is to facilitate Server GC-level performance but with memory use more inline with what the application actually needs based on the current load, i.e. it will start out small (e.g. small number of heaps, low allocation budget) and then grow and shrink based on the application's allocation patterns.

While we don't feel this new mode is ready to be the default for all apps using Server GC at this stage, it will be the default in ASP.NET Core projects set to use native AOT (<PublishAot>true</PublishAot>) in .NET 8. It was suggested that in addition to that, a good click-stop for .NET 8 would be to use this new mode as the default mode in our .NET 8 ASP.NET Core container images.

@mthalman
Copy link
Member

cc @richlander

How is this mode set? Is it a publish option? If so, how would that apply to the aspnet image which just contains the runtime and not a published app.

@richlander
Copy link
Member

I assume this is an ENV.

@jkotas
Copy link
Member

jkotas commented Jun 20, 2023

cc @Maoni0

@DamianEdwards
Copy link
Member Author

Actually it's a runtime configuration knob, so can be set via project property, runtime config file, or environment variable AFAIK

@sebastienros
Copy link
Member

Seems like both are needed:
DOTNET_gcServer=1
DOTNET_GCDynamicAdaptationMode=1

@Maoni0
Copy link
Member

Maoni0 commented Jun 20, 2023

you always need to enable Server GC (which asp.net already does anyway).
the runtime config is System.GC.DynamicAdaptationMode

@richlander
Copy link
Member

Actually it's a runtime configuration knob, so can be set via project property, runtime config file, or environment variable AFAIK

This request is only relevant if we want to override the default via ENV.

@richlander
Copy link
Member

I took away from our conversations that we are not going to make this automatic, but encourage users to set a project property, which will then affect all of their usage. Is that correct?

@eerhardt
Copy link
Member

I took away from our conversations that we are not going to make this automatic, but encourage users to set a project property, which will then affect all of their usage. Is that correct?

Have we landed on this decision? If so, can this be closed?

@DamianEdwards
Copy link
Member Author

I think we concluded that we wouldn't do this so I'll close this.

@github-project-automation github-project-automation bot moved this from Backlog to Done in .NET Docker Jul 12, 2023
@tomachristian
Copy link

@Maoni0 what did you mean here? I am struggling to figure out / find any reference of whether the GC Server mode is enabled by default using the default dotnet container images.

you always need to enable Server GC (which asp.net already does anyway).

@jkotas
Copy link
Member

jkotas commented Feb 2, 2025

@tomachristian Default dotnet container images do not override GC settings. The GC mode is determined by the application deployed into the image or by additional environment variables that you can set when building the container with your application.

ASP.NET applications have GC server enabled by default. Console applications have GC server disabled by default. You can override these defaults by setting ServerGarbageCollection msbuild property when building the application; or by setting DOTNET_gcServer environment variable when the application runs. More details in https://learn.microsoft.com/en-us/dotnet/core/runtime-config/garbage-collector#workstation-vs-server .

@tomachristian
Copy link

Thank you, @jkotas!

@tomachristian
Copy link

tomachristian commented Feb 3, 2025

@jkotas we were trying to enable the Server GC and we noticed that DOTNET_gcServer is not the same as DOTNET_GCSERVER, I can't believe it is all about the casing... can you please confirm?

Later edit: dotnet/runtime#64393 yeah, they are different :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

8 participants