Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent GC fails to run concurrently #13238

Open
nalywa opened this issue Aug 9, 2019 · 4 comments
Open

Concurrent GC fails to run concurrently #13238

nalywa opened this issue Aug 9, 2019 · 4 comments
Labels
area-GC-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@nalywa
Copy link

nalywa commented Aug 9, 2019

I'm seeing an occasional issue on netcore 2.2 where a concurrent Gen2 GC seems to not run on the background GC thread, instead running on the thread that triggered the collection.

This was observed on my Windows 10 development running an app in Release configuration on the 64-bit .NET Core 2.2 runtime with the default GC profile (workstation, concurrent GC enabled, interactive latency mode), and I was able to grab a perfview sample of the occurence:

blockingConcurrentGC

Looking through the GC source, I think there may be an issue introduced in this commit. Before the change, bgc_thread would be set at the time of thread creation, and would be guaranteed to be set by the time it's checked in void gc_heap::garbage_collect (int n). After the change, bgc_thread is now set within the new thread at the start of it's execution, which seems like it would introduce a race condition where that field may not be set in time for concurrent GC to continue.

@Maoni0
Copy link
Member

Maoni0 commented Aug 9, 2019

ahh, good find!
@PeterSolMS, @VSadov would one of you please take a look and make a fix?

@Maoni0
Copy link
Member

Maoni0 commented Aug 9, 2019

just wanted to point out that the actual GC done here is no longer a BGC - it just treats it as we failed to create the BGC thread so we are simply doing a full blocking GC; the event is misleading (it still says Background) so that should also be fixed in case we fail to actually do a BGC (failed to create the BGC thread or for any other reason).

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 5.0 milestone Jan 31, 2020
@Maoni0
Copy link
Member

Maoni0 commented Jul 14, 2020

for the race of setting bgc_thread, we actually don't need to to set it in bgc_thread_stub, in CreateSuspendableThread after this line

args.Thread = SetupUnstartedThread(FALSE);

the Thread object is already available - all the later logic in this function doesn't change the Thread that got created anyway.

@mangod9 mangod9 modified the milestones: 5.0.0, Future Aug 12, 2020
@VSadov VSadov removed their assignment Dec 3, 2020
@ssandif
Copy link

ssandif commented Dec 13, 2022

+1

Wanted to make sure this issue wasn't lost in the dotnet/coreclr to dotnet/runtime move, noticed it hasn't been active since 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-GC-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

6 participants