Skip to content

runtime(coro): bind executor driver to scheduler - #26

Merged
cpunion merged 4 commits into
llvm-corofrom
coro/phase17-executor-driver
Jul 16, 2026
Merged

runtime(coro): bind executor driver to scheduler#26
cpunion merged 4 commits into
llvm-corofrom
coro/phase17-executor-driver

Conversation

@cpunion

@cpunion cpunion commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • bind one stable ExecutorRegistry generation and one WaitRegistrationTable to a scheduler-owned single P
  • make running PollPreempt observe executor requests without acknowledging them
  • add scheduler-owned drain, acknowledge, unconditional source recheck, idle arm/commit, wake, and close lifecycles
  • enforce wait-table ownership and reject legacy RequestSchedule while an executor is bound
  • fail closed at command and final-G terminal boundaries until the production close handoff exists
  • update the coroutine runtime design with the implemented contract and remaining blockers

Concurrency protocol

Platform producers retain only POD wait and executor handles. They publish a durable wait slot before requesting the executor. The running G may repeatedly observe Requested, but only the scheduler-owned driver can drain sources and acknowledge the request.

Idle entry is PollExecutor, ArmIdle, an unconditional full durable-source scan, exact CommitSleep, then a target retained-doorbell wait. Wake first leaves IdleArmed and then repeats drain, acknowledge, and source recheck. Close requires no parked G or live registration, seals the executor gate, relies on a strong target unregister/join, then retires and unbinds the stable generation.

Validation

  • go test ./runtime/internal/coro
  • go test -race -shuffle=on -count=30 ./runtime/internal/coro
  • go test -race -run ExecutorDriver -count=100 ./runtime/internal/coro
  • go vet ./runtime/internal/coro
  • Go cross-compilation for js/wasm, wasip1/wasm, linux/arm, and linux/riscv64
  • LLGo current-source package build of runtime/internal/coro

Scope

This is still a target-neutral single-P driver. It is not wired into production runtime/internal/runtime/coroRun and does not implement a native, WASM/JS, WASI, RTOS, or baremetal retained-doorbell backend. The last-G executor close/join/unbind/retry handoff is an explicit production blocker and intentionally fails closed in this phase.

Stacked on #25.

@cpunion
cpunion changed the base branch from coro/phase16-executor-gate to llvm-coro July 16, 2026 19:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ExecutorDriver to manage the bridge between the ExecutorRegistry and WaitRegistrationTable for single-P scheduling. It adds necessary state tracking to the P struct and implements the driver lifecycle, including binding, polling, and terminal state handling. The review feedback identifies a potential nil pointer dereference, suggests idiomatic return value handling, points out a potential state inconsistency, and notes redundant code, all of which include actionable code suggestions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread runtime/internal/coro/scheduler.go
Comment thread runtime/internal/coro/executor_driver.go
Comment thread runtime/internal/coro/executor_driver.go Outdated
Comment thread runtime/internal/coro/wait_registration.go Outdated
@cpunion
cpunion force-pushed the coro/phase17-executor-driver branch from cdb1941 to a11bd25 Compare July 16, 2026 19:22
@cpunion
cpunion merged commit 155eca5 into llvm-coro Jul 16, 2026
6 checks passed
@cpunion
cpunion deleted the coro/phase17-executor-driver branch July 16, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant