Repository navigation
refactor: split the green scheduler into modules and bring its comments up to date - #1236
Merged
Merged
Conversation
…ken tasks to their waker by default
# Conflicts: # cranelift/runtime/src/concurrency/green.rs
# Conflicts: # cranelift/runtime/src/concurrency/green.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1235. No behavior change.
The green scheduler is split into modules by concern.
concurrency/green.rswas one 3,200-line file. It is nowconcurrency/green/:mod.rsis_donetask.rsSyncBlock, join, the arena, task idsqueues.rsPinnedQueueandStealQueuewake.rsworker.rsWorkerand its cache, the worker loop, finding and stealing work, parkingrun.rspreempt.rsstack.rsstats.rsPITH_GREEN_STATScountersprobe.rstests.rsThe code moved as is. Items used across modules are now
pub(super), andmod.rsre-exports what the rest of the runtime calls, so outside paths (green::wake,green::encode_probe,green::PITH_PREEMPT_REQUESTED) are unchanged.Comments describe the current design. The module doc was a phase-by-phase history (P1a, P2, P2b, P2c) with a synchronization section that still described the slab and the
Arcjoin. It is now a short overview: what blocks and how, which module owns what, the placement rules and the lock order. Comments that referred to the retired slab or slab lock, or narrated earlier designs, now state the current behavior. Thepith_green_maybe_yielddoc said it setswake_pending; it setspreempt_pending.Struct counts. In
runtime_core.rs, the struct retain, release, weak retain and weak release paths repeated the "local count or atomic count" step inline with fully qualifiedstd::sync::atomic::Orderingpaths. They now call two#[inline(always)]helpers,count_upandcount_down. The atomics import moved from the middle of the file to the top.Lock-order notes.
channel.rs,semaphore.rs,waitgroup.rsanddocs/concurrency.mdsaidwaketakes the slab lock. It takes only the scheduling word and one run-queue lock.Green unit tests, the cross-thread resume test and the TLS-barrier check pass. The full local gates run on the combined branch.