Skip to content

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

Description

@prattmic

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 then calls wakep from schedule, 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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeGarbageCollectorNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions