Skip to content

max_cpu_share alone should determine the hard cap in a workload setting, even if max_cpus is unset - #88217

Merged
serxa merged 13 commits into
ClickHouse:masterfrom
neeravsalaria:fix_cpu_limit_max_cpu_share
Oct 13, 2025
Merged

serxa merged 13 commits into
ClickHouse:masterfrom
neeravsalaria:fix_cpu_limit_max_cpu_share

Conversation

@neeravsalaria

@neeravsalaria neeravsalaria commented Oct 8, 2025 •

Copy link
Copy Markdown
Contributor

In workload settings, the effective hard CPU cap (max_cpus) is determined as the minimum of two potential limits: (1) an explicit hard cap (max_cpus) and (2) a cap derived from the share (max_cpu_share × number_of_cores). When neither the workload nor its parents specify max_cpus, the resolver treats the explicit cap as zero (unset).

Per the documentation (), it’s valid to configure a workload with only max_cpu_share and no max_cpus. However, when only max_cpu_share is provided, the current resolver does not initialise a hard cap from the share; instead, it leaves max_cpus at zero. Practically, this means no hard ceiling is applied even though a share cap exists, leading to larger short-window bursts than operators expect.

Observed behavior

With max_cpu_share set and max_cpus unset, the effective hard cap remains 0 (i.e., no hard ceiling is established from the share).

Expected behavior

If max_cpus is unset and max_cpu_share is set, the resolver should initialise the hard cap from the share (i.e., max_cpu_share × number_of_cores) so that a sensible hard ceiling exists even without an explicit max_cpus.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixes a workload setting max_cpu_share. Now it can be used without max_cpus workload setting being set.

@CLAassistant

CLAassistant commented Oct 8, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1b43602]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan, old analyzer, 2/6) failure
test_keeper_disks/test.py::test_logs_with_disks FAIL
Integration tests (amd_asan, old analyzer, 4/6) failure
test_ddl_worker_with_loopback_hosts/test.py::test_ddl_worker_with_loopback_hosts FAIL

@pamarcos
pamarcos requested a review from serxa October 8, 2025 16:28

@serxa serxa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 8, 2025
@wiraphatys

Copy link
Copy Markdown

I'm waiting for this PR merging btw. Thanks god 🙏🏻

@serxa

serxa commented Oct 10, 2025

Copy link
Copy Markdown
Member

@neeravsalaria As for the CustomResourceManager, it would be okay to just return a default-constructed WorkloadSettings. The notion of workload is not present there.

@serxa

serxa commented Oct 10, 2025

Copy link
Copy Markdown
Member

@wiraphatys @MoosaTae There is a simple workaround if you want to use the feature without the fix. Just use a high value for max_cpus along with correct max_cpu_share:

CREATE WORKLOAD workload_name IN parent_workload SETTINGS max_cpus = 9999, max_cpu_share = 0.5

@serxa serxa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great. Let's see what CI says

@neeravsalaria

neeravsalaria commented Oct 10, 2025 •

Copy link
Copy Markdown
Contributor Author

@serxa , any idea why the CI tests are failing.

@serxa

serxa commented Oct 10, 2025

Copy link
Copy Markdown
Member

@serxa , any idea why the CI tests are failing.

These tests are flaky, no worries. We'll merge it if there is no related test failure.

@neeravsalaria

Copy link
Copy Markdown
Contributor Author

@serxa , any idea why the CI tests are failing.

These tests are flaky, no worries. We'll merge it if there is no related test failure.

Awsome. Thanks

@serxa
serxa enabled auto-merge October 10, 2025 23:26
@MoosaTae

Copy link
Copy Markdown

@wiraphatys @MoosaTae There is a simple workaround if you want to use the feature without the fix. Just use a high value for max_cpus along with correct max_cpu_share:


CREATE WORKLOAD workload_name IN parent_workload SETTINGS max_cpus = 9999, max_cpu_share = 0.5

Thank you🙏🙏

@serxa
serxa added this pull request to the merge queue Oct 13, 2025
Merged via the queue into ClickHouse:master with commit b3498bd Oct 13, 2025
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 13, 2025
robot-clickhouse added a commit that referenced this pull request Oct 13, 2025
…d cap in a workload setting, even if max_cpus is unset
robot-clickhouse added a commit that referenced this pull request Oct 13, 2025
…d cap in a workload setting, even if max_cpus is unset
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 13, 2025
clickhouse-gh Bot added a commit that referenced this pull request Oct 13, 2025
Backport #88217 to 25.9: max_cpu_share alone should determine the hard cap in a workload setting, even if max_cpus is unset
clickhouse-gh Bot added a commit that referenced this pull request Oct 13, 2025
Backport #88217 to 25.8: max_cpu_share alone should determine the hard cap in a workload setting, even if max_cpus is unset
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants