, 9 tweets, 5 min read
We've been playing with the GC knobs @maoni0 added in .NET Core. By tweaking how much Gen 0 budget and heap count we want on 48 core machines for smaller apps, we have a lot better memory usage.

No more super lazy semi-unbounded gen 0 growth making things hard to get a read on:
@maoni0 One downside with some of the tweaks on the various knows is it's not super well documented (somewhat by design) and I had to poke at which limits were global, per-heap, etc. After we get some of this shipped, I'll be submitting some PRs on the .NET documentation to help others.
@maoni0 For context: on a multi-tenant machine (e.g. many apps on a web tier), lazy collection is problematic.

Example: we have a web tier with 64 GB. Some apps are using up to 4GB when they need a few hundred meg. Is it a bug? A leak? Or is GC just being lazy? No clue without dumps.
@maoni0 Note: collection is globally triggered when memory is around 80-85%, which signals memory pressure to all apps and GC kicks in. But a leak or growth issue may go undetected next to other apps for way too long. We need predictability to monitor and access. Here's that web tier:
@maoni0 For the app in that graph, what we're doing for this IIS in-proc hosted ASP.NET Core 3.0 app is in web.config:
<environmentVariable name="COMPLUS_GCHeapCount" value="0xA" />
<environmentVariable name="COMPLUS_GCGen0MaxBudget" value="0x3200000" /><!-- 50MB/heap -->
@maoni0 The GC knobs are documented here: github.com/dotnet/coreclr…

For environmental variables, you're prefixing with "COMPLUS_".

Note: if you want to see where they are used, you need to manually grep gc.cpp, since it's so large, GitHub doesn't index it: github.com/dotnet/coreclr…
@maoni0 For a breakdown of that app - here's what it looks like internally, with 10 heaps now (instead of 48) and much lower gen 0 limits. Only the *actual* long-lived cache items are sticking around, i.e. things we actually need memory for \o/:
@maoni0 If you're curious how to quickly analyze memory dumps - there are several tools out there. I wrote a quick LinqPad script a while back to answer common questions we care about. It's in a gist here: gist.github.com/NickCraver/d62…

Take a memory dump (e.g. task manager) and have some fun!
Added a small PR for updating the GC docs in hopes it helps the next person: github.com/dotnet/coreclr…
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Nick Craver

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!