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

runtime: stopped Ms can't become dedicated or fractional GC workers #44313

Open
prattmic opened this issue Feb 16, 2021 · 0 comments
Open

runtime: stopped Ms can't become dedicated or fractional GC workers #44313

prattmic opened this issue Feb 16, 2021 · 0 comments
Assignees
Milestone

Comments

@prattmic
Copy link
Member

@prattmic prattmic commented Feb 16, 2021

When a GC starts, Ms are enlisted to run a dedicated or fractional GC worker via a call to findRunnableGCWorker early in schedule.

This is problematic for Ms blocked in findrunnable, which never calls findRunnableGCWorker, and thus cannot run dedicated or fractional GC workers. findrunnable can run idle-priority GC workers, and thus the GC work should get done regardless, but this is going to become particularly problematic if idle-priority GC is removed (#44163).

The typical flow should look something like:

  1. Normal goroutine calls gcStart.
  2. During the process of starting GC, startTheWorldWithSema calls wakep, waking an M stopped in findrunnable.
  3. The woken M runs a GC mark worker at idle-priority.
  4. The M from (1) eventually enters the scheduler and calls findRunnableGCWorker, running a dedicated GC mark worker, and calls wakep, waking another M stopped in findrunnable.
  5. The woken M runs a GC mark worker at idle-priority.

If the Ms at (3) and (5) are not spinning (which they won't be if it will be fully stopped), I don't believe there will be anymore wakep calls, thus limiting the total number of workers to a maximum of three.

FWIW, I don't think it should be fundamentally difficult to move a findRunnableGCWorker check into findrunnable.

This is somewhat related to #39004, another case of a source of work not reachable from findrunnable (though in that case there is no wakep at all).

cc @mknyszek @aclements

@prattmic prattmic added this to the Go1.17 milestone Feb 16, 2021
@prattmic prattmic self-assigned this Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant