Skip to content

runtime(coro): add stable executor request gate - #25

Merged
cpunion merged 3 commits into
llvm-corofrom
coro/phase16-executor-gate
Jul 16, 2026
Merged

runtime(coro): add stable executor request gate#25
cpunion merged 3 commits into
llvm-corofrom
coro/phase16-executor-gate

Conversation

@cpunion

@cpunion cpunion commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a fixed-capacity stable ExecutorRegistry with POD slot/generation handles
  • coalesce running requests and distinguish the only idle transition that needs a platform doorbell
  • add exact ArmIdle, CommitSleep, LeaveIdle, Acknowledge, close, quiesce, retire, and generation-reuse protocols
  • publish durable wait completion before requesting its executor
  • document the retained-doorbell and post-backend-join final-drain contracts

Concurrency protocol

A running compiler safepoint only observes Requested and yields. The scheduler owns acknowledgement and must drain, acknowledge, then recheck every durable source. Idle entry is ArmIdle, source recheck, exact CommitSleep, then a target retained wait. Close races Request through an exact zero-to-Closed CAS and strong backend join covers the complete platform shim, including the doorbell tail.

Deterministic tests cover drain-to-ack coalescing, ArmIdle versus Request, wake before physical block, Post-to-Request idle and shutdown windows, close races, admitted producer pinning, stale generations, and capacity exhaustion.

Validation

  • go test ./runtime/internal/coro
  • go test -race -shuffle=on -count=20 ./runtime/internal/coro
  • go vet ./runtime/internal/coro
  • Go cross-compilation for js/wasm, wasip1/wasm, linux/arm, and linux/riscv64
  • LLGo package build of runtime/internal/coro
  • generated LLGo IR retains CommitSleep as seq_cst cmpxchg with old and new value 2

Scope

This is the target-neutral request-gate layer. It deliberately does not yet bind the gate to P, PollPreempt, the scheduler idle driver, or a real native/WASM/WASI/RTOS/baremetal backend. Those are the next stacked phases.

@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 a target-neutral ExecutorRegistry to manage stable executor request gates, providing a mechanism for safe, allocation-free platform executor wakeups. It includes the core registry implementation and comprehensive tests verifying lifecycle management, idle handshakes, and concurrency. The review feedback suggests refactoring complex state validation logic in Register and CanRelease to improve readability and reduce code duplication.

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/executor_request.go
Comment thread runtime/internal/coro/executor_request.go
@cpunion
cpunion merged commit 5253adb into llvm-coro Jul 16, 2026
6 checks passed
@cpunion
cpunion deleted the coro/phase16-executor-gate branch July 16, 2026 19:21
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