Reputation: 373
I am trying to improve performance on a single threaded computationally intensive / low IO .NET 4.7.1 program by analyzing it in perfview, running on Windows Server 2016 in AWS on a r5.8xlarge instance (32 core, 256GB RAM).
I took a 700s sample of my process in perfview (including the -threadtime flag), and I see the following results for GC
along with these > 200ms pause events
Looking at the first slow GC Index 149056, with a pause time of 12,270.571ms, does that mean that my managed code is literally stopped between 2,522.622ms and 14,793.193ms? (=2522.622+12270.571) while I'm waiting for Gen 2 GC to finish?
If that's true, when I look at Thread Time stacks over that time window, and I look at BLOCKED_TIME only for my main thread (using IncPats), I see many different functions that wind up in BLOCKED_TIME.
I've redacted the lines that are my functions that wind up calling clr!JIT_New, but there are about 20 different ones.
If the managed threads are paused for GC during this time window, then wouldn't there just be a single call from my code that winds up in BLOCKED_TIME?
Upvotes: 1
Views: 253
Reputation: 21
Looking at the first slow GC Index 149056, with a pause time of 12,270.571ms, does that mean that my managed code is literally stopped between 2,522.622ms and 14,793.193ms? (=2522.622+12270.571) while I'm waiting for Gen 2 GC to finish?
No it's a background GC and runs concurrently with your managed threads but 12 seconds is very long time for a gen 2 collection.
I am trying to improve performance on a single threaded computationally intensive / low IO .NET 4.7.1 program by analyzing it in perfview, running on Windows Server 2016 in AWS on a r5.8xlarge instance (32 core, 256GB RAM).
Consider changing it to Server GC if it's possible to reduce pauses and improve the performance of your project by reducing GC impact on your app and do the GC on multiple threads instead of single thread
Reduce the finalizable objects because it can impact the object allocation and garbage collection performance and use Dispose method on disposable objects instead of relying on fianlizer.
Reduce the cross references from gen 2 -> gen 0 because it can slow down every gen 0 GC and makes GC to scan some objects from gen 2 to make sure the gen 0 objects can be collected safely
Make sure the references to short lived objects are cleared so the GC can do the marking phase faster(which is the most time consuming part of GC most of the time)
avoid allocating large objects(arrays most of the time) whenever possible so it does gen 2 GCs less frequently
Upvotes: 1