Skip to content
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

Swoole fix setAffinity call on Mac #327

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Backends/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ function (Process $worker) use ($maxMessageLength, $queueItem) {
true,
);

$workerProcess->setAffinity([$currentCpu]);
if (method_exists($workerProcess, 'setAffinity')) {
$workerProcess->setAffinity([$currentCpu]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this looks like it's telling the worker process to bind to a particular unit. Is that right? Does this provide some performance enhancement? Does it still work as intended without setting the CPU affinity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work as intended; yeah it will be slower on mac because I think it will cause more context switching.

I added that on top of the other changes, so it wasn't the primary driver behind the performance gains.

}

$workerProcess->setBlocking(false);
$workerProcess->start();

Expand Down
Loading