Skip to content

Commit c66dbae

Browse files
[release/10.0] [mono][sgen] Fix incorrect condition when checking if we should do a major collection (#120532)
Backport of #120432 to release/10.0 /cc @BrzVlad ## Customer Impact - [x] Customer reported - [ ] Found internally This impacts all platforms using mono. A customer reported a 40x regression on an XML Serialization benchmark when moving from .NET8 to .NET9. This regression is caused by the runtime triggering excessive GCs due to a bug in the heuristic. This is more likely to happen if the GC concurrent sweep phase takes longer and the application allocates large objects frequently. This likely impacts many applications, but with less noticeable performance impact. ## Regression - [x] Yes - [ ] No This regressed in .NET9 ## Testing Tested the fix on sample benchmark that it works correctly. ## Risk Low risk. The fix is localized and the previous condition was blatantly wrong by mistake. Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
1 parent 6d0c7d7 commit c66dbae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mono/mono/sgen/sgen-memory-governor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ sgen_need_major_collection_conservative (void)
141141
size_t max_allowance = GDOUBLE_TO_SIZE (max_last_collection_heap_size * SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO);
142142
max_allowance = MAX (max_allowance, GDOUBLE_TO_SIZE (MIN_MINOR_COLLECTION_ALLOWANCE));
143143

144-
return min_heap_size > max_allowance;
144+
return min_heap_size > (max_last_collection_heap_size + max_allowance);
145145
}
146146

147147
static size_t

0 commit comments

Comments
 (0)