question

KrzysztofMadej avatar image
0 Votes"
KrzysztofMadej asked MughundhanRaveendran-MSFT commented

How to change GC Mode on Azure Function App hosted In-Process

I want to test my Function app written in C# (dotnet 6) with different GC mode. The app is hosted on dedicated Linux plan with server GC mode. I set DOTNET_gcServer to 0 but System.Runtime.GCSettings.IsServerGC is strill true, and memory consumtpion remain the same. How can I change GC mode for app hosted In-Process?

dotnet-csharpazure-functions
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KrzysztofMadej ,

In which file are you setting the DOTNET_gcServer to 0?
How are you identifying that the System.Runtime.GCSettings.IsServerGC is still set to true?

0 Votes 0 ·

@KrzysztofMadej ,

Following up to see if the answer that was provided by me helped. Do let me know if you have any queries.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

the GC mode is not settable with azure functions. also as they are always a single cpu with 1.5 gb max memory, its aways the same as workstation mode.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MughundhanRaveendran-MSFT avatar image
0 Votes"
MughundhanRaveendran-MSFT answered MughundhanRaveendran-MSFT commented

Hi @KrzysztofMadej ,

Thanks for reaching out to Q&A forum.

By default, the GC mode in Azure functions is server GC. We have kept it as server GC for best performance and memory management. The major difference between these 2 GC flavors is WKS GC has one heap and SVR GC has as many heaps as there are logical cores on the machine, with the same # of GC threads doing GC work. Due to the different nature of the 2 kinds of workloads, SVR GC has 2 distinctly different attributes that WKS GC does not have -

  • SVR GC threads' priority is set to THREAD_PRIORITY_HIGHEST which means it would preempt other threads if they were lower priority, which most theads are. In comparison, WKS GC runs the GC work on the user thread that triggered the GC so it's whatever priority that thread runs at which is usually normal priority.

  • SVR GC threads are hard affinitized to logical cores.

So for an Azure functions running on a consumption plan, the GC really doesnt make a difference as it would only run on a single core with 1.5 GB RAM. However if you choose a higher SKU such as premium or dedicated P3V3 plan with more number of cores, it would be ideal to keep the GC mode as SVR GC.

Learn more about Server GC : https://github.com/Maoni0/mem-doc/blob/master/doc/.NETMemoryPerformanceAnalysis.md#server-gc

I hope this helps and you would choose to have SVR GC in Azure functions. Please let me know if you would still like to change to WKS GC.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KrzysztofMadej ,

Following up to see if the above answer helps. Do let me know if you have any queries.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

0 Votes 0 ·