Skip to content

cluster: add schedulingPolicy to settings #41731

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yashLadha
Copy link
Contributor

Added schedulingPolicy option to settings so that the cluster owners
can schedule the handler explicitly as well. They can use the name
either rr or none for setting up the schedulingPolicy of
the primary process.

@nodejs-github-bot nodejs-github-bot added cluster Issues and PRs related to the cluster subsystem. needs-ci PRs that need a full CI run. labels Jan 28, 2022
schedulingPolicy = cluster.schedulingPolicy; // Freeze policy.
assert(schedulingPolicy === SCHED_NONE || schedulingPolicy === SCHED_RR,
`Bad cluster.schedulingPolicy: ${schedulingPolicy}`);
schedulingPolicy = SCHEDULE_POLICY_NAME_MAP.get(cluster.schedulingPolicy); // Freeze policy.
Copy link
Contributor

@mscdex mscdex Jan 28, 2022

Choose a reason for hiding this comment

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

Should we be keeping the assert() to ensure settings.schedulingPolicy maps to a supported value in SCHEDULE_POLICY_NAME_MAP?

Copy link

@Mifrill Mifrill Dec 5, 2023

Choose a reason for hiding this comment

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

As I understand, it should be handled via SafeMap above:
https://github.com/yashLadha/node/blob/9027b55935784c5e40ac54db5919895ad1636f16/lib/internal/cluster/primary.js#L47-L49
so the value of settings.schedulingPolicy can be only supported in SCHEDULE_POLICY_NAME_MAP. Hence the assert is redundant in this particular case.

} else
schedulingPolicy = SCHED_RR;

cluster.schedulingPolicy = schedulingPolicy;
Copy link
Contributor

@mscdex mscdex Jan 28, 2022

Choose a reason for hiding this comment

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

We need to keep this (cluster.schedulingPolicy) and consider its value to avoid breaking things.

Added `schedulingPolicy` option to settings so that the cluster owners
can schedule the handler explicitly as well. They can use the name
either `rr` or `none` for setting up the schedulingPolicy for setting up
the primary process.
@yashLadha yashLadha force-pushed the cluster_policy_setting branch from 1549ad8 to 9027b55 Compare January 29, 2022 06:59
@aduh95 aduh95 added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 29, 2022
@aduh95
Copy link
Contributor

aduh95 commented Jan 29, 2022

That's adding an option, so it's semver-minor, right? We'd need to add an entry in the changes list in the YAML comment if that's the case.

@mscdex
Copy link
Contributor

mscdex commented Jan 29, 2022

I think it makes more sense to have settings.schedulingPolicy use the direct values like cluster.schedulingPolicy. The reason we have the string representations is to support setting from process.env.

Additionally, I think the changes here can be simplified by leaving the original top-level initialization of (cluster.)schedulingPolicy and then simply having schedulingPolicy: options.schedulingPolicy || cluster.schedulingPolicy in settings. Then we would just do schedulingPolicy = settings.schedulingPolicy and leave the pre-existing assert() to ensure schedulingPolicy holds a valid/supported value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants