Skip to content

node: cpumgr: metrics: add uncore cache alignment metrics#129529

Closed
ffromani wants to merge 5 commits intokubernetes:masterfrom
ffromani:split-l3-metrics
Closed

node: cpumgr: metrics: add uncore cache alignment metrics#129529
ffromani wants to merge 5 commits intokubernetes:masterfrom
ffromani:split-l3-metrics

Conversation

@ffromani
Copy link
Copy Markdown
Contributor

@ffromani ffromani commented Jan 8, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Add alignment metrics for uncore (aka last-level) cache (KEP-4800)

Which issue(s) this PR fixes:

Part of the work needed for KEP 4800: kubernetes/enhancements#4800

Special notes for your reviewer:

N/A

Does this PR introduce a user-facing change?

Add metrics to track allocation of Uncore (aka last-level aka L3) Cache blocks

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 8, 2025
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 8, 2025
@ffromani ffromani marked this pull request as ready for review January 21, 2025 10:45
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Jan 21, 2025
@ffromani ffromani changed the title WIP: node: cpumgr: metrics: add L3 alignment metrics node: cpumgr: metrics: add L3 alignment metrics Jan 21, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 21, 2025
@ffromani
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-node-kubelet-serial-containerd
/test pull-kubernetes-node-kubelet-serial-containerd-sidecar-containers
/test pull-kubernetes-node-kubelet-serial-cpu-manager
/test pull-kubernetes-node-kubelet-serial-hugepages
/test pull-kubernetes-node-kubelet-serial-memory-manager
/test pull-kubernetes-node-kubelet-serial-topology-manager

@ffromani
Copy link
Copy Markdown
Contributor Author

/hold

mistakes in the e2e tests

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2025
@ffromani
Copy link
Copy Markdown
Contributor Author

/hold cancel

e2e tests should be fixed now

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2025
@ffromani
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-node-kubelet-serial-containerd
/test pull-kubernetes-node-kubelet-serial-containerd-sidecar-containers
/test pull-kubernetes-node-kubelet-serial-cpu-manager
/test pull-kubernetes-node-kubelet-serial-hugepages
/test pull-kubernetes-node-kubelet-serial-memory-manager
/test pull-kubernetes-node-kubelet-serial-topology-manager

@ffromani
Copy link
Copy Markdown
Contributor Author

known issue, investigating

@ffromani ffromani changed the title node: cpumgr: metrics: add L3 alignment metrics node: cpumgr: metrics: add uncore cache alignment metrics Jan 21, 2025
@ffromani ffromani force-pushed the split-l3-metrics branch 2 times, most recently from cbf7801 to 5eb4bba Compare January 22, 2025 16:58
@ffromani
Copy link
Copy Markdown
Contributor Author

/hold cancel

needs more approval anyway :)
The PR is reviewable!

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 22, 2025
Copy link
Copy Markdown
Contributor Author

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

notes to self:
things I'm ok with but not completely happy still

Comment thread pkg/kubelet/cm/cpumanager/alignment.go Outdated
limitations under the License.
*/

package cpumanager
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

still not completely happy about where this code lives

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this all falls under topology alignment so topology seems like the right place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My only concern is that I want to merge the alignment logic with physical-cpus alignment logic once this PR merged and moving into topology could backfire on this.

Comment thread pkg/kubelet/cm/cpumanager/alignment.go Outdated
return fmt.Sprintf("aligned=<uncore:%v>", ca.UncoreCache)
}

func NewAlignment(topo *topology.CPUTopology, cpus cpuset.CPUSet) Alignment {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should probably be renamed CheckAlignment or so

Comment thread pkg/kubelet/cm/cpumanager/alignment.go Outdated
}
}

func isAlignedAtUncoreCache(topo *topology.CPUTopology, cpuList ...int) bool {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

does this belong in topology?
We know we want to clean up the current code and merge the physical cpu alignment check logic with this one (makes no sense to split it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tend to agree! I think this should be part of topology.

Copy link
Copy Markdown
Contributor

@swatisehgal swatisehgal left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this!
I left a few comments but will do another pass later.

I found it a bit hard to review this because there was quiet some refactoring coupled with new additions. Can we try to split the work into smaller commits to split the refactoring work and new metrics addition?

Comment thread test/e2e_node/cpu_manager_metrics_test.go
Comment on lines +336 to +339
"kubelet_container_aligned_compute_resources_count": gstruct.MatchElements(idFn, gstruct.IgnoreExtras, gstruct.Elements{
"container::uncore_cache": timelessSample(1),
}),
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you help me understand this? We have one metric that captures alignment at various boundaries (e.g. NUMA, uncore_cache, physical CPUs) and here we check for an element (in this case uncore_cache) in that? Why this approach rather than separate alignment metrics altogether?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because AFAIK is more idiomatic in prometheus to have related logical metrics grouped in the same metric and differentiate by labels. There are other examples in the codebase, albeit our metrics are kinda inconsistent

Comment thread pkg/kubelet/cm/cpumanager/alignment.go Outdated
limitations under the License.
*/

package cpumanager
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this all falls under topology alignment so topology seems like the right place.

Comment thread pkg/kubelet/cm/cpumanager/alignment.go Outdated
}
}

func isAlignedAtUncoreCache(topo *topology.CPUTopology, cpuList ...int) bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tend to agree! I think this should be part of topology.

@ffromani
Copy link
Copy Markdown
Contributor Author

/retest-required

unrelared apiserver failure

@ffromani
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-node-kubelet-serial-containerd
/test pull-kubernetes-node-kubelet-serial-containerd-sidecar-containers
/test pull-kubernetes-node-kubelet-serial-cpu-manager
/test pull-kubernetes-node-kubelet-serial-hugepages
/test pull-kubernetes-node-kubelet-serial-memory-manager
/test pull-kubernetes-node-kubelet-serial-topology-manager

Comment thread pkg/kubelet/cm/cpumanager/policy_static_test.go Outdated
Comment thread pkg/kubelet/cm/cpumanager/policy_static_test.go Outdated
@swatisehgal
Copy link
Copy Markdown
Contributor

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 30, 2025
Comment thread pkg/kubelet/cm/cpumanager/topology/alignment.go
abort the test in the unlikely case we fail to create
the Policy object. Exactly because this is unlikely
we should fail loudly.

In my case this happened because unrelated bad parameters,
which was hard to catch

Signed-off-by: Francesco Romani <fromani@redhat.com>
There's no need to use the generic reflect.DeepEqual,
we can use the cpuset Equals method in tests,
which is more idiomatic and a tad clearer.

Signed-off-by: Francesco Romani <fromani@redhat.com>
get nicer output for free

Signed-off-by: Francesco Romani <fromani@redhat.com>
fix test name. Cosmetic only.

Signed-off-by: Francesco Romani <fromani@redhat.com>
add missing metric about uncore / L3 / Last-Level cache alignment,
plus its e2e tests.

Exposing uncore alignment requires a bit of refactoring in the static
policy implementation because, differently from full PCPUs alignment
and NUMA alignment, can't be easily and safely inferred by construction.

The main reason for this is that uncore cache alignment is preferred,
not mandatory, thus the cpu allocator can legally use cross-uncore
allocation. Because of that, the final cpuset union step can
create a final cpuset which is not uncore-aligned even though all
its parts are uncore-aligned.

The safest way seems thus to run just a final uncore-alignment check
once the final cpuset is computed.

Signed-off-by: Francesco Romani <fromani@redhat.com>
@ffromani
Copy link
Copy Markdown
Contributor Author

/retest-required

@ffromani
Copy link
Copy Markdown
Contributor Author

continuing on #130133

@ffromani ffromani closed this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants