Skip to content

Conversation

@omerap12
Copy link
Member

@omerap12 omerap12 commented Jan 9, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds the --round-cpu-millicores flag to the VPA recommender, enabling user-configurable rounding of CPU recommendations.

Which issue(s) this PR fixes:

Fixes #7678

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`--round-cpu-millicores` flag to the VPA recommender

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

Documentation updated to include the `--round-cpu-millicores` flag in the recommender feature set.  

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 9, 2025
@k8s-ci-robot k8s-ci-robot requested a review from jbartosik January 9, 2025 15:04
@k8s-ci-robot k8s-ci-robot requested a review from kgolab January 9, 2025 15:04
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 9, 2025
Signed-off-by: Omer Aplatony <[email protected]>
Comment on lines 37 to 38
humanizeMemory = flag.Bool("humanize-memory", false, "Convert memory values in recommendations to the highest appropriate SI unit with up to 2 decimal places for better readability.")
roundCPUMillicores = flag.Int("round-cpu-millicores", 1, `CPU recommendation rounding factor in millicores. The CPU value will be rounded to the nearest multiple of this factor.`)
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious what others think, but I like the idea of these two options being similar.
humanize-memory + humanize-cpu
or
round-memory-mebibyte + round-cpu-millicores

I haven't though through if this is possible or not. So I'm unsure if my idea is a good one or not, but for some reason keeping the options similar just feels like it may be a good user experience.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean you want to combine these two flags into a single one?

Copy link
Member

@adrianmoisey adrianmoisey Jan 12, 2025

Choose a reason for hiding this comment

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

That is another option...
--humanize=cpu,memory

Or two flags:

--humanize-memory=true/false
--humanize-cpu=true/false

I'm not strongly opinionated on the direction we go, I do think more opinions may be useful

Copy link
Member Author

Choose a reason for hiding this comment

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

but the cpu rounding depends on the user input, as it rounds to the nearest multiple of a specified factor. So, I'm not sure how the boolean flag is helpful here - unless you're suggesting that we should always round to a specific factor.

Copy link
Member

Choose a reason for hiding this comment

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

unless you're suggesting that we should always round to a specific factor.

☝️ this

Does it make sense to have the "memory rounding feature" and the "cpu rounding feature" to operate in similar ways? Either ask a user to input a factor, or to use the humanize feature for both

Copy link
Member

Choose a reason for hiding this comment

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

They would select the mebibyte's to round up to

Copy link
Member

Choose a reason for hiding this comment

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

(I don't know if this is a good idea or not, to be honest)

Copy link
Member Author

Choose a reason for hiding this comment

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

But if the user would want GiB? or TiB (not sure it's possible but still )..

Copy link
Member

Choose a reason for hiding this comment

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

Aaaahhhhhh, ok! I see the problem now.
They are both "rounding", but the difference between a few millicore, or a few memory units (GiB, TiB) is quite different.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup!

--humanize-memory=true
```

## CPU Recommendation Rounding
Copy link
Member

Choose a reason for hiding this comment

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

+1 for adding docs as the feature is added! This is a habit we need to be getting into

Copy link
Member Author

Choose a reason for hiding this comment

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

yup! Thank you :)

Co-authored-by: Adrian Moisey <[email protected]>
@adrianmoisey
Copy link
Member

Don't forget to run vpa-generate-flags.go

Signed-off-by: Omer Aplatony <[email protected]>
@adrianmoisey
Copy link
Member

/milestone vertical-pod-autoscaler-1.4.0

@adrianmoisey
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 17, 2025
@alekc
Copy link

alekc commented Jan 28, 2025

Just fiy, there are some bugs around memory implementation of humanize, see #7770 (might affect this one as well if it has followed the same approach)

@adrianmoisey
Copy link
Member

Just fiy, there are some bugs around memory implementation of humanize, see #7770 (might affect this one as well if it has followed the same approach)

Yup, thanks. Omer (author of this PR and the assignee of #7770) is aware of the issue.

@omerap12
Copy link
Member Author

Just fiy, there are some bugs around memory implementation of humanize, see #7770 (might affect this one as well if it has followed the same approach)

I know about this bug, but this change is simpler and doesn’t use the humanize memory method.

Copy link
Member

@raywainman raywainman left a comment

Choose a reason for hiding this comment

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

Small documentation nit then this is good to go, thanks Omer! :)

lowerBoundMemoryPercentile = flag.Float64("recommendation-lower-bound-memory-percentile", 0.5, `Memory usage percentile that will be used for the lower bound on memory recommendation.`)
upperBoundMemoryPercentile = flag.Float64("recommendation-upper-bound-memory-percentile", 0.95, `Memory usage percentile that will be used for the upper bound on memory recommendation.`)
humanizeMemory = flag.Bool("humanize-memory", false, "Convert memory values in recommendations to the highest appropriate SI unit with up to 2 decimal places for better readability.")
roundCPUMillicores = flag.Int("round-cpu-millicores", 1, `CPU recommendation rounding factor in millicores. The CPU value will be rounded to the nearest multiple of this factor.`)
Copy link
Member

Choose a reason for hiding this comment

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

Should we specify that it is always rounded up?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree: 6645e94

Signed-off-by: Omer Aplatony <[email protected]>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 31, 2025
@omerap12
Copy link
Member Author

Small documentation nit then this is good to go, thanks Omer! :)

No problem :)

Comment on lines 41 to 49
VPA can provide CPU recommendations rounded to user-specified values, making it easier to interpret and configure resources. This feature is controlled by the `--round-cpu-millicores` flag in the recommender component.

When enabled, CPU recommendations will be:
- Rounded to the nearest multiple of the specified millicore value
- Applied to target, lower bound, and upper bound recommendations

For example, with `--round-cpu-millicores=50`, a CPU recommendation of `79m` would be rounded to `100m`, and a recommendation of `34m` would be rounded to `50m`.

To enable this feature, set the --round-cpu-millicores flag when running the VPA recommender:
Copy link
Member

Choose a reason for hiding this comment

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

Does it also make sense to say "rounded up" in this section? Just to drive home that it's up, not down.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in a6a1e1c

Signed-off-by: Omer Aplatony <[email protected]>
@raywainman
Copy link
Member

/lgtm

/approve

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 31, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: omerap12, raywainman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 31, 2025
@k8s-ci-robot k8s-ci-robot merged commit 8e980c0 into kubernetes:master Jan 31, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Implement Rounding for CPU Recommendations in VPA

5 participants