Skip to content

Complete runtime scheduler preemption#433

Merged
heartwilltell merged 3 commits into
mainfrom
codex/runtime-scheduler-preemption
Apr 26, 2026
Merged

Complete runtime scheduler preemption#433
heartwilltell merged 3 commits into
mainfrom
codex/runtime-scheduler-preemption

Conversation

@heartwilltell

Copy link
Copy Markdown
Contributor

Summary

  • Enables multi-P runtime scheduling to run reliably with more than one P, including safe idle-M tracking, locked idle-P checks, and waking parked Ms when the last G completes.
  • Adds actual SIGURG delivery from a runtime preemption thread to running M threads and routes interrupted Gs through async preemption trampolines.
  • Makes ARM64 async preemption look like an injected call by preserving the interrupted LR and returning through the resume PC, and strengthens the amd64/arm64 trampoline register saves.
  • Updates runtime scheduler tests to allow RUN_MAXPROCS overrides, use atomics under multi-P execution, validate multi-P progress, and prove SIGURG preempts a tight loop.

Fixes #399
Fixes #401

Notes

Validation

  • zig fmt build.zig src/*.zig src/runtime/run_xev_bridge.zig
  • clang-format -i src/runtime/run_scheduler.c src/runtime/run_scheduler.h src/runtime/tests/test_main.c src/runtime/tests/test_scheduler.c
  • zig build
  • zig build test (passes; command prints the expected negative missing() diagnostic from the test fixture)
  • zig build test-runtime
  • RUN_MAXPROCS=2 zig build test-runtime

@heartwilltell heartwilltell self-assigned this Apr 26, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 26, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
runlang 505c482 Commit Preview URL

Branch Preview URL
Apr 26 2026, 10:44 AM

@heartwilltell heartwilltell marked this pull request as ready for review April 26, 2026 10:44
@heartwilltell heartwilltell merged commit 98cc3fa into main Apr 26, 2026
14 checks passed
@heartwilltell heartwilltell deleted the codex/runtime-scheduler-preemption branch April 26, 2026 11:31
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.

Use libxev async/notify for scheduler wakeup Complete signal-driven preemption (SIGURG) for tight loops Enable multi-P scheduling

1 participant