Skip to content

Preparation for work-stealing scheduler - #319

Merged
lalinsky merged 2 commits into
mainfrom
work-stealing-prep1
Feb 11, 2026
Merged

lalinsky merged 2 commits into
mainfrom
work-stealing-prep1

Conversation

@lalinsky

Copy link
Copy Markdown
Owner
  • Remove LIFO slot for now
  • Prevent tasks from running multiple time per event loop tick

Simplifies the scheduler in preparation for work stealing.
All tasks now go through the ready_queue (FIFO).
@coderabbitai

coderabbitai Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR removes LIFO slot optimization from the runtime scheduler and replaces it with monotonic tick-based execution control. Tasks now execute FIFO from the ready queue, with per-task last_run_tick tracking preventing re-execution within a single tick. The scheduleTaskLocal API is simplified, removing the is_yield parameter.

Changes

Cohort / File(s) Summary
Scheduler Core Refactor
src/runtime.zig
Removed LIFO slot fields (lifo_slot, lifo_slot_enabled, lifo_slot_used); added current_tick: u32 = 1 to Executor. Reworked getNextTask to pure FIFO-based ready_queue selection with last_run_tick validation. Simplified scheduleTaskLocal(self, task) signature, removing is_yield parameter. Updated all call sites, task migration, and event loop to increment current_tick per tick.
Task Tracking
src/runtime/task.zig
Added last_run_tick: u32 = 0 field to AnyTask struct for per-executor tick tracking to prevent multiple executions within the same event loop tick.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

Farewell, LIFO slot so spry,
No more pinning tasks on high—
Now ticks march on, FIFO flows,
Each task runs once per tick it goes. ⏱️

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preparation for work-stealing scheduler by removing LIFO slot optimization and adding tick-based execution control.
Description check ✅ Passed The description directly relates to the changeset, covering the two main objectives: removing LIFO slot and preventing multiple task executions per tick.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch work-stealing-prep1

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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