Make native select differential deterministic#21
Conversation
📝 WalkthroughWalkthroughThe select syntax example updates sender delays and increases both timeout values so the first selection targets channel ChangesSelect syntax example
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/select_syntax.mko`:
- Around line 13-17: Update the setup around chan_selectn in the first select
test so b’s sender is confirmed to have started or become ready before kicking
the delayed sender for a. Replace the fixed-delay-only ordering with an explicit
synchronization mechanism, while preserving the existing intent that only b is
selectable initially and retaining the current select timeout and values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a2ffe787-54e6-4a30-8414-2b2fd8cb648d
📒 Files selected for processing (1)
examples/select_syntax.mko
| // Keep only b ready for the first select. A large gap prevents a busy | ||
| // CI runner from making both buffered channels ready before selection. | ||
| let _ = t.kick(sender(a, 11, 500)) | ||
| let _ = t.kick(sender(b, 22, 0)) | ||
| select timeout 2000 { |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the ordering guarantees of crew kickoff and channel readiness.
rg -n -C5 '\bt\.kick\s*\(|fn\s+kick\b|sleep_ms\b|chan_select' .Repository: loreste/mako
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== candidate crew definitions =="
rg -n -C8 '\bkick\b|struct .*Crew|type .*Crew|impl .*Crew|fn new_crew|Crew::|t\.kick' src runtime examples/testing examples/select_syntax.mko --glob '!runtime/native_bridge.c' | head -n 240
echo
echo "== select_syntax.mko and chan_select implementation references =="
cat -n examples/select_syntax.mko
rg -n -C7 'select|chan_select' runtime src --glob '!runtime/native_bridge.c' | head -n 220Repository: loreste/mako
Length of output: 29009
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== focused crew/channel/select runtime symbols =="
rg -n -C6 'struct mako_crew|type mako_crew|crew_\w*|Crew|kick\(|chan_new|chan_send|chan_select|mako_chan_select|mako_native_chan_select|selectn|selectn' runtime src -g '*.c' -g '*.h' -g '*.rs' | head -n 300
echo
echo "== relevant exact files if any =="
git ls-files | rg '(^|/)(?i)(crew|select|channel|thread|task).*\.(c|h)$|(^|/)(mako_rt|mako_vm|mako_sched).*\.(c|h)$|src/.*select.*|src/.*crew.*'Repository: loreste/mako
Length of output: 16622
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== runtime/mako_rt.h relevant ranges =="
sed -n '5030,5115p' runtime/mako_rt.h
sed -n '5115,5150p' runtime/mako_rt.h
sed -n '5440,5515p' runtime/mako_rt.h
sed -n '5590,5660p' runtime/mako_rt.h
echo
echo "== crew kickoff and scheduling references =="
rg -n -C8 'kick|Crew|crib|Task|task|spawn|thread|pthread|schedule|runnable|ready|selectn\(|chan_selectn\(' runtime/mako_rt.h runtime -g '*.c' -g '*.h' --glob 'runtime/mako_rt.h'Repository: loreste/mako
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== exact ranges requested =="
sed -n '5030,5115p' runtime/mako_rt.h
sed -n '5115,5150p' runtime/mako_rt.h
echo
echo "== select-n implementation candidates =="
rg -n -C10 'mako_chan_selectn|static inline .*select.*' runtime/mako_rt.h
echo
echo "== crew/task implementation candidates =="
rg -n -C10 'struct .*Task|struct .*Crew|typedef .*Task|typedef .*Crew|kick\(|Kick\(|pthread_create|pthread_mutex|pthread_cond|runnable|ready|spawn|join' runtime/mako_rt.h --glob 'runtime/mako_rt.h'Repository: loreste/mako
Length of output: 50368
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== crew/task implementation tail =="
wc -l runtime/mako_rt.h
sed -n '5646,5950p' runtime/mako_rt.h
echo
echo "== select syntax lowering =="
rg -n -C8 'Select|stmts|ChanSelect|select_syntax|mako_chan_select' src --glob '*.rs'Repository: loreste/mako
Length of output: 50369
Wait for b’s send to start before delaying a.
chan_selectn starts scanning from the current round-robin index, so if both buffered channels become ready before the first select, either arm can be chosen. A fixed delay does not guarantee a is still unavailable, so the test remains scheduler-dependent; establish readiness ordering between kicking/beginning the delayed sender and the first select.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@examples/select_syntax.mko` around lines 13 - 17, Update the setup around
chan_selectn in the first select test so b’s sender is confirmed to have started
or become ready before kicking the delayed sender for a. Replace the
fixed-delay-only ordering with an explicit synchronization mechanism, while
preserving the existing intent that only b is selectable initially and retaining
the current select timeout and values.
Make native select differential deterministic
Summary
Validation
Summary by CodeRabbit