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

Add cpu_weight config, relates to Systemd's CPUAccounting and CPUWeight #125

Closed
wants to merge 7 commits into from

Conversation

ticoneva
Copy link

This PR introduces a new configuration option cpu_weight. This sets the systemd property CPUWeight, which causes available CPU time to be sliced in proportion to each user's weight.

This is a follow-up to PR #98.

@consideRatio consideRatio changed the title Cpu weight Add cpu_weight config, relates to Systemd's CPUAccounting and CPUWeight May 31, 2023
Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

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

Nice @ticoneva, this makes sense to me!!

  • I believe but don't know that CPUAccounting and CPUWeight are supported by systemd v245 and later. Do you know that we can assume these to be around in systemd v245?
  • Resolution to comment about setting CPU_WEIGHT environment variable

Comment on lines +291 to +293
if self.cpu_weight:
env["CPU_WEIGHT"] = str(self.cpu_weight)

Copy link
Member

Choose a reason for hiding this comment

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

To add a new env var here sets a new precendece for systemdspawner of passing environment variables related to the config set.

I suspect this can add to maintenance burden long term, so I suggest this is removed unless there is a solid motivation for retaining it.

I know some information about system constraints can be detected in a standardized ways, for example as done in dask/distributed. So if this is relevnat information for the user environment, maybe it can be captured in a similar way?

@@ -304,6 +319,11 @@ async def start(self):
properties["CPUAccounting"] = "yes"
properties["CPUQuota"] = f"{int(self.cpu_limit * 100)}%"

if self.cpu_weight is not None:
# FIXME: Detect & use proper properties for v1 vs v2 cgroups
Copy link
Member

Choose a reason for hiding this comment

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

I've seen similar comments, but I don't know much about it, so I feel quite inactionable about these FIXME comments overall.

Are these systemd settings only valid in certain contexts with regards to available cgroup versions?

Comment on lines +232 to +234
This info is exposed to the single-user server as the environment variable
`CPU_WEIGHT` as an integer.

Copy link
Member

Choose a reason for hiding this comment

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

Related to discussion in another comment about not setting this env var.

@behrmann
Copy link
Contributor

I believe but don't know that CPUAccounting and CPUWeight are supported by systemd v245 and later. Do you know that we can assume these to be around in systemd v245?

They are around in that form since at least systemd 241, but my memory is a bit hazy since they might require cgroup v2, which legacy versions of distros might not yet use, but the hybrid cgroup layout should be fine.

@consideRatio
Copy link
Member

consideRatio commented May 31, 2023

I made an investigation about the fixme notes in #126 @behrmann, and opened #127 to remove them. What do you think? My conclusion is that we don't need them, because its handled by systemd no matter what.

@consideRatio
Copy link
Member

@behrmann I opened #128 also, thinking maybe cpu_weight shouldn't be added, but that instead we should ensure its easy to pass through CPUQuota config without declaring a new dedicated python based config option in SystemdSpawner.

What are your thoughts about doing that?

@yuvipanda
Copy link
Collaborator

Sorry for the much delayed review here, @ticoneva.

I agree with @consideRatio here that we should move towards allowing people to pass through params directly to systemd, instead of special casing them here. With that, I'm going to close this PR.

@yuvipanda yuvipanda closed this Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants