Repository navigation
Closed
Labels
Milestone
Description
Issue
- We run our ConversationService app on NetCore 8 in AKS Linux Containers using COSMIC platform for management and orchestration plane.
- We have a perf bench running regularly in our SDF (flighting) environment which simulates 1000 users joining a Teams meeting @ roughly 166 joins per second
- After rolling out upgrade to NetCore 10.0.11, elf build-id 989b56dfb2782aa230f822ee4c520e2ccfea71b7 in a subset of clusters, we started seeing this perf workload degrade in terms of number of failed joins as well as their tail latencies.
- Analyzing the difference in KHI between a sample worst and best run among a flight of runs, I noticed that
- Threadpool worker thread count was the highest order difference to throughput, it was significantly higher in bad runs, meaning we need to explain the extra thread blocking.
- Analyzing CPU/Cswitch events from good and bad runs I found that
- Bad run has 30% more thread blocking overall
- Threads are blocked in GCEvent::Impl::Wait roughly 2.5X in bad runs (trapped at a safe point because EE is suspended for GC)
- Threads are blocked 4X more time on GCHeap::Alloc in bad runs (waiting to allocate on mostly SOH)
- Bad runs were found to have fewer GC heaps than good runs and the performance results (API latencies, operation failures) degraded proportional with decrease in heaps
- The extreme case of this were runs which had the worst outcomes and had a single SVR::gc_heap for at least the first 60 seconds (the most crucial part with the most stress) of the run, despite us having a 6.9 core CPU limit configured.
- Occurrence rate was about 1 in every 15 perf runs had this tail behavior with single heap, many more runs had 5 heaps and the better runs has 7 heaps (the limit)
Rootcause Summary
- DATAS is the highest value enablement from net8->net10 which can explain variable heap counts
- So I started analyzing CLR GC Events from these extreme tail runs to see where DATAS was stuck at 1 heap despite clear MSL contention and was able to find 4 issues that interplay and contribute to varying degrees to this outcome.
- Issue 1: The accumulated MSL wait times are zero and not contributing to TCP despite the app seeing sustained high MSL lock contention
-
This seems to be an issue introduced in this commit when we changed the implementation of SVR::gc_heap::get_msl_wait_time, we seem to be missing a pointer de-reference when it accumulates into soh_msl_wait_time and uoh_msl_wait_time.
-
-
After GC these counters are reset meaning what we lost can never come back
-
The issue is not just cosmetic (not just dictates the values we see in SizeAdaptationSample_V1) but also dictates what DATAS uses as input to calculate throughput cost.
-
Its also not been fixed yet in dotnet 10 servicing or dotnet 11 AFAIK
-
In fact IMHO MSL wait times ought to be the primary indicator of TCP because
- It’s the leading indicator - threads see allocation contention first, and high GC pause time is a lagging indicator (but not be much in most scenarios)
- GC pause time can fluctuate and be affected by a lot of different things - MSL contention (at least from the profiles) is more explicit and higher quality signal that we need more parallelism, and we need it fast.
- This is my gut feeling without actual MSL data but going by cswitch waits on MSL: GC pause time has a higher chance of being smoothened out in subsequent DATAS stages and would take a longer time to converge on selecting a heap count upgrade
- Depending on the workload, there may also be other cases where MSL will save us while GC pause times are low, although that should be rare and certainly not the case here.
-
- The lack of MSL wait time in TCP is not a factor in this specific case
- The GC pause signal itself was un-ambiguously high and sustained its TCP error / debt enough to survive smoothening, filtering, dampening etc of the TCP signal and request heap count 1->5 10 times.
- Why did the active heap count always remain at 1 despite requesting 1 -> 5 at least 10 times?
- There are actually 2 reasons why this happened:
- Reason 1 (Main contributor):
- A single BGC index/count 38138 was active for 55 overlapping seconds of the trace and thus blocked every opportunity for SVR::gc_heap::check_heap_count to run. More on this interesting bit later.
- Issue 2: SVR::gc_heap::check_heap_count is not given an opportunity to execute when BGC concludes
- Although it might not have helped in this case, where we think a single BGC was active for ~55 seconds, it should be readily apparent that SVR::gc_heap::check_heap_count is very important to execute at the earliest opportunity when its possible for it to run
- In fact I would call for Feature 1
- Feature ask 1: See if its possible to introduce co-operative cancellation of ongoing BGC at safe points (which will have every opportunity to run later and continue working on Gen2)
- So that SVR::gc_heap::check_heap_count has a chance to run faster, especially when its not the first (or second, or third) time a heap count change is found to be warranted.
- Likely not trivial at all: Aborting would require a new phase-specific rollback/completion protocol for mark arrays, write-watch and overflow state, weak/finalization processing, partial sweep/free-list state, locks, joins, and allocation contexts.
- But at least can we think of co-operative cancellation that is designed to break the self-reinforcing loop that I describe below, when we detect frequent and high Gen1->Gen2 promotions keep extending time in BGC?
- Reason 2 (Lesser contributor)
- Issue 3: DATAS adjustment bookkeeping can credit a proposed correction as successful soon after proposal, without checking if SVR::gc_heap::check_heap_count actually ran to completion
- dynamic_heap_count_data.record_adjustment(…) runs when the request is calculated, before the later apply.
- Cancellation paths such as on BGC do not roll back adjustment history.
- Thus, un-applied adjustments are being taken into account to further dampen and react even slower to sustained high TCP, by crediting a proposal which was never applied.
- Issue 3: DATAS adjustment bookkeeping can credit a proposed correction as successful soon after proposal, without checking if SVR::gc_heap::check_heap_count actually ran to completion
- Reason 1 (Main contributor):
- There are actually 2 reasons why this happened:
- Issue 4: A single BGC active for so long? Hunch: It’s a self-reinforcing loop driven by high (and frequent) Gen1->Gen2 promotion from ForegroundGC
- This work is pending: I have not rootcaused yet, but plan to try
- The informed best guess based on observed Gen1->Gen2 survival rate from ForegroundGC (and the frequency this happens at) suggests we have a self-reinforcing loop:
- Only 1 heap + One 64 MiB aggregate Gen0 budget + 1 GC worker + 1 BGC worker (latter happens to be in-progress when allocation rate surge starts)
- -> Frequent, high-survival Foreground GCs promoting lots of objects Gen1->Gen2
- -> Ongoing BGC is repeatedly parked because Gen1->Gen2 survivors keep up the BGCRevisit pressure
- -> Pending DATAS-driven 1-to-5 heap count growth remains gated on BGC completion
- -> One heap persists, and we are in a self-sustaining loop which keeps producing frequent, high-survival foreground GCs promoting lots of objects to Gen2 and doing so frequently
- -> Pending DATAS-driven 1-to-5 heap count growth remains gated on BGC completion
- -> Ongoing BGC is repeatedly parked because Gen1->Gen2 survivors keep up the BGCRevisit pressure
- -> Frequent, high-survival Foreground GCs promoting lots of objects Gen1->Gen2
- Only 1 heap + One 64 MiB aggregate Gen0 budget + 1 GC worker + 1 BGC worker (latter happens to be in-progress when allocation rate surge starts)
- I need to start collecting Microsoft-Windows-DotNETRuntimePrivate:0x1:5 that supplies detailed BGC phase/work markers to confirm / deny this hypothesis.
- GC revisits written/dirtied pages from Gen1->Gen2 promotions from the Foreground GCs is evident in source - but its magnitude is not yet measured
- The decisive private events are BGCRevisit (dirtied pages and newly marked objects) and BGCDrainMark , correlated with BGC phase boundaries.
- If hypothesis holds, while being strongly self-reinforcing, this is not a deadlock
- It is driven by sustained allocation pressure and thus Gen1->Gen2 promotion
- A backoff in allocation pressure (as happens in our process within the first few minutes of every top of hour traffic spike) will frequently converge the heap count to what is actually desired
- But in the meantime we have caused low reliability for our APIs at traffic peaks when we need it the most.
- Feature ask 2: (Tongue in cheek, please forgive me) What if we were able to apply heap count upgrade (unidirectional) when necessary not just on DATAS path, but also on the SOH allocation path itself?
- For those familiar only with native heap managers which don’t have the magic of GC, decreasing allocation contention by creating new heaps / arenas happens only on the allocation path, exactly when its needed and when it will have the most benefit.
- So the fact that we are not immediately alleviating contention at the point at which the contention exists and instead waiting for a later event when allocations (which are being throttled by the contention) reach a budget, could seem counter-intuitive.
- Want to add one more concern from out end: This was very hard to diagnose UNTIL we took traces with SizeAdaptationTuning events etc.
- Feature ask 3: Can you please track an item to expose more of the salient DATAS tuning inputs and outputs as observable telemetry, instrument, eventcounters etc?
- Input side
- MSL lock wait times
- Time in GC suspension (which of course we have proxies for)
- Output side (both proposed and active)
- Generation budgets
- Heap counts
- Input side
- This can make DATAS observable while running the service and we feel its important to have especially since its the default now.
- Feature ask 3: Can you please track an item to expose more of the salient DATAS tuning inputs and outputs as observable telemetry, instrument, eventcounters etc?
Mitigation path
- For all the above mentioned reasons: DATAS is less reactive than our needs dictate
- After evaluating its internals and understanding how it smoothens, dampens and has high bar (in our POV) for moving in both directions, especially heap count that dictates degree of parallelism, we think its not a good fit for the kind of performance our workloads call for.
- The above reported issues certainly don’t help, but even if they were fixed, I don’t imagine DATAS is for us going forward for a few reasons.
- I don’t (yet) see a pathway to tune it for our workloads
- Reducing TCP threshold may be helpful but only to some extent
- Our app is a real-time workload where throughput is VERY sensitive to new areas of thread synchronization and drop in throughput is VERY visibl e to the user (meeting join time inflation is more visible than say an email arriving a little later)
- For large meeting calls with lots of invitees, when the calls start, our pods can experience HUGE swing in concurrent resource demand and transition from average to outlier perf very quickly
- Our workload at these periods of stress becomes very sensitive to any friction in obtaining access to the reserved memory and CPU we booked for our container.
- Additionally from a user experience perspective, this happens exactly at the time when large calls starts which is also most crucial time period in our own code to bootstrap scale measures and features to distribute load for the call to alleviate pressure and handle it well
- Customer perception of call quality in first few seconds/minutes of large (and thus important) calls disproportionately affects their product satisfaction
- Our app thus is designed for a world where reserve more resources and over-provision for the peaks, and the large call ramp-up stress (even though from the POV of a single pod it’s a very rare occurrence)
- We are thus wary of releasing resources to OS or neighboring containers, a design that has been continuously carried over fro m the RDFE model where we were the only major app to whom the entire VM is dedicated.
- Unfortunately our design is not elastic enough to operate any other way right now
- So, we will be turning off DATAS in our dotnet 10 clusters, and if our design needs change we will re-assess where DATAS can help us conserve our footprint
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
dotnet-policy-service commentedon Sep 23, 2026
Tagging subscribers to this area: @anicka-net, @dotnet/gc
See info in area-owners.md if you want to be subscribed.
subbucse commentedon Sep 23, 2026
@Maoni0 , @mangod9 : There are more artifacts for this issue, such as profiles, event captures and other evidence etc that I have shared privately over email.
subbucse commentedon Sep 24, 2026
@janvorli ^ .
Fix msl wait time extraction in GC (#135022)
[release/10.0] Fix msl wait time extraction in GC (#135228)
[release/11.0] Fix msl wait time extraction in GC (#135097)