Refactor scheduler #532
Labels
A-interface
Area: Interface/API
A-work-queue
Area: Work queue
C-refactoring
Category: Refactoring
P-normal
Priority: Normal.
TODO list
GCWorkScheduler
and eliminate the need to use excessiveOption<T>
fields.ControllerCollectorContext
GCRequester
away fromBasePlan
. Let global states be global.- Related issue: Cleaning up OOP-style inheritance and the impls of Deref #587
- Fixed in Move some states from BasePlan to GlobalState #949
Problem
Currently, the
GCWorkScheduler
serves multiple purposes.GCWorker
for the GC controller thread. This part should be owned by the GC controller thread.This part should be shared between threads.
On the other hand, there is currently no "context" object for the GC controller thread.
ControllerCollectorContext
contains therun()
method for the GC controller, but it also serves as the communication hub for triggering GC.GCWorker
in the scheduler. It spends most of its lifetime inGCWorkScheduler::wait_for_completion
. Even its communication channel is owned byGCWorkScheduler.channel.1
.And the
ControllerCollectorContext
-- which apparently has nothing to do with a "plan" --** is buried deep insidemmtk.plan.base().controller_collector_context
**. We consider a "plan" to be a description of a GC algorithm, butBasePlan
holds mostly the global GC states. Understandably, the controller thread itself is one of such global state, but it is really plan-agnostic.The initialisation process is complicated. When initialising, all GC algorithms pass a
scheduler
object to theinit()
function of theControllerCollectorContext
.GCWorkScheduler
also uses manyOption<T>
fields and initializes itself unsafely.These phenomena are a result of porting MMTk from Java to Rust. Java's programming style promotes shared states and inter-referenced objects, while Rust emphasises ownership. This requires us to think more carefully about the ownership of data.
Goal
The goal is to ensure each thread owns the data that it accesses exclusively, and ensure shared data are properly identified, shared and synchronised. Threads we concern include:
Mutators and VM-specific non-mutator threads (such as OpenJDK's "VM Thread") are not part of our concern.
Data structures we concern include:
ControllerCollectorContext
GCWorkScheduler
MMTK
The text was updated successfully, but these errors were encountered: