-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Ring loop dispatch #10100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.7.x
Are you sure you want to change the base?
Ring loop dispatch #10100
Conversation
📝 WalkthroughWalkthroughA new atomic counter using ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/http.php (2)
70-71
: Fix the non-standard hyphen character in the comment.The comment contains a non-standard hyphen character (‑) which could cause issues with text processing tools.
- $start = $nextWorker->add(1) % $totalWorkers; // ring‑buffer start index + $start = $nextWorker->add(1) % $totalWorkers; // ring-buffer start index
67-146
: Consider adding validation for edge cases.While the implementation is solid, consider adding validation for edge cases such as
$totalWorkers
being 0, which would cause division by zero in the modulo operations.function dispatch(Server $server, int $fd, int $type, $data = null): int { + global $totalWorkers; + if ($totalWorkers <= 0) { + throw new \InvalidArgumentException("Total workers must be greater than 0"); + } + $resolveWorkerId = function (Server $server, $data = null) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/http.php
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
🔇 Additional comments (4)
app/http.php (4)
50-50
: LGTM: Atomic counter introduction is well-implemented.The use of
\Swoole\Atomic\Long
is appropriate for thread-safe counter operations in the Swoole environment.
76-77
: LGTM: Ring-buffer implementation for general case is correct.The worker selection logic correctly implements round-robin distribution while preserving the idle worker preference.
113-114
: LGTM: Ring-buffer implementation for risky workers is correct.The logic correctly constrains the search to risky workers only (from
$riskyWorkers
to$totalWorkers-1
) while using the ring-buffer approach.
130-131
: LGTM: Ring-buffer implementation for safe workers is correct.The logic correctly searches through all workers for idle ones while using the ring-buffer approach.
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
✨ Benchmark results
⚡ Benchmark Comparison
|
What does this PR do?
(Provide a description of what this PR does and why it's needed.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist