-
Notifications
You must be signed in to change notification settings - Fork 30k
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
lib: refactored scheduling policy assignment #32663
lib: refactored scheduling policy assignment #32663
Conversation
lib/internal/cluster/master.js
Outdated
}; | ||
|
||
// XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings? | ||
let { [process.env.NODE_CLUSTER_SCHED_POLICY]: schedulingPolicy } = schedulingPolicies; |
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.
lint-js rule check error is triggered :)
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.
Yes, my bad. Done 👍
c93cf14
to
2579e7f
Compare
@nodejs/cluster |
I'm really rather lukewarm when it comes to changes like this one. I might be biased because I wrote the current code but the new code is arguably less readable than the code it replaces. |
@bnoordhuis is it specific to destructuring or the naming. Just wanted to know the cause 😄 |
The destructuring. It's not that it's incredibly complex or difficult to follow, just harder to parse than the current code (IMO.) |
@bnoordhuis what should be the correct approach then according to you, because previously we are pulling the scheduling policy straight out from the hash which is not implying anything in general. 🤔 |
Well, if you want to make an improvement, how about this? let schedulingPolicy = process.env.NODE_CLUSTER_SCHED_POLICY;
if (schedulingPolicy === 'rr')
schedulingPolicy = SCHED_RR;
else if (schedulingPolicy === 'none')
schedulingPolicy = SCHED_NONE;
else if (process.platform === 'win32')
// Round-robin doesn't perform well on Windows due to the way IOCP is wired up.
schedulingPolicy = SCHED_NONE;
else
schedulingPolicy = SCHED_RR; That at least protects It's a marginal improvement but marginal improvements are improvements too. :-) |
2579e7f
to
bc2ba78
Compare
In previous implementation it was clubbed into declaration of scheduling policies and fetching the schedulingPolicy. Now they are separate variables, so that in future if one want to add new scheduling policy. It is much simpler and not obsfucated.
bc2ba78
to
4985a2e
Compare
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.
lgtm
In previous implementation it was clubbed into declaration of scheduling policies and fetching the schedulingPolicy. Now they are separate variables, so that in future if one want to add new scheduling policy. It is much simpler and not obsfucated. PR-URL: #32663 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Landed in 023bcde |
In previous implementation it was clubbed into declaration of scheduling policies and fetching the schedulingPolicy. Now they are separate variables, so that in future if one want to add new scheduling policy. It is much simpler and not obsfucated. PR-URL: #32663 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
In previous implementation it was clubbed into declaration of scheduling policies and fetching the schedulingPolicy. Now they are separate variables, so that in future if one want to add new scheduling policy. It is much simpler and not obsfucated. PR-URL: #32663 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
In previous implementation it was clubbed into declaration of scheduling
policies and fetching the schedulingPolicy. Now they are separate
variables, so that in future if one want to add new scheduling policy.
It is much simpler and not obsfucated.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes