-
Notifications
You must be signed in to change notification settings - Fork 68
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
Remove the coordinator (controller) thread #1053
Comments
We used to believe that the coordinator (controller) thread was introduced to handle STW for OpenJDK (which requires the thread that starts and stops the world to be the same). But from the source code of JikesRVM, it appears that the controller thread existed in JikesRVM, too. The I think we already agreed that we can remove the coordinator thread. To implement this change, however, we need to acknowledge that we are deviating from JikesRVM. We probably have a good reason to do this, that is, we now use work packets. We still need to implement a GC-triggering algorithm that is equivalent to the old ControllerCollectorContext. For now, it should be as simple as adding the |
The coordinator thread behaves like an implicit state machine: WaitForGC -> ScheduleGC -> OpenMoreBuckets -> OpenMoreBuckets -> ... -> GcFinished -> WaitForGC After removing the coordinator thread, GC workers coordinate themselves. Specifically when all GC workers parked, the last parked worker shall perform actions.
We need an explicit state machine for this. The simplest design will have only two states: It is tempting to use the |
This PR removes the coordinator (a.k.a. controller) thread, and allows temporarily terminating and restarting all GC worker threads in order to support forking. Major changes include: - `GCController` is removed. All synchronization mechanisms involving the controller are removed, too. Important synchronization operations, such as opening buckets and declaring GC finished, are done by the last parked worker. The work packet `EndOfGC` is removed, and its job is now done by the last parked worker. - The `WorkerMonitor`, which previously synchronizes between GC workers, now also synchronizes between mutators and GC workers. This allows mutators to trigger GC by directly communicating with GC workers. - Introduced a new mechanism: "goals". Mutators can now request "goals", and GC workers will work on one goal at a time. Currently, a "goal" can be either GC or StopForFork. Triggering GC is now implemented as requesting the GC goal. - Added a pair of new APIs, namely `MMTK::prepare_to_fork()` and `MMTK::after_fork()`. VM bindings call them before and after forking to let the MMTK instance do proper preparation for forking. Fixes: #1053 Fixes: #1054
It was created because OpenJDK requires the thread that stops the world to be the same thread that starts the world. But now the OpenJDK binding uses a dedicated "companion" thread for that purpose.
The coordinator thread has brought much trouble to the synchronization with GC workers, and it has been changed many time for that. With the concept of "coordinator work" removed in #794, the coordinator thread is now only used to respond to GC triggers. We realized that we can remove the coordinator and the GC workers can coordinate themselves.
Removing the coordinator thread can also save one context switch between the last GC worker starting sleeping and the coordinator thread opening new buckets.
The text was updated successfully, but these errors were encountered: