Skip to content

topology-aware: try picking resources by hints first #545

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

Merged
merged 7 commits into from
Jul 2, 2025

Conversation

klihub
Copy link
Collaborator

@klihub klihub commented Jul 1, 2025

This PR updates how topology hints are taken into account during resource allocation, especially when there are multiple devices with different HW locality allocated to a single container. In particular the PR

  • gives more priority for topology hints, bringing them just below explicitly annotated affinity
  • updates CPU allocation to try pick CPUs by pod resource API hints first
  • updates memory allocation to pick memory nodes by pod resource API hints first
  • updates the helm charts values to include agent setting defaults for enabling NRT and pod resource API

Notes: This behavioral change is currently not put behind a config option or an annotation yet. I intend to do that however, by pushing an additional commit.

@klihub klihub requested review from kad, marquiz and fmuyassarov July 1, 2025 07:49
@klihub klihub force-pushed the devel/pick-resources-by-hints branch from a7edac8 to 00a510a Compare July 1, 2025 07:58
Copy link
Collaborator

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

With a very quick pass on this, looks sane to me 😅 With a potentially "might not be a good idea" I'd suggest to start with an off-by-default configuration option.

Spotted one typo in one commit message With multiple devices allocated to a since container

@klihub klihub force-pushed the devel/pick-resources-by-hints branch from 00a510a to 6b88f9e Compare July 1, 2025 08:31
@klihub
Copy link
Collaborator Author

klihub commented Jul 1, 2025

With a very quick pass on this, looks sane to me 😅 With a potentially "might not be a good idea" I'd suggest to start with an off-by-default configuration option.

Yes, definitely. I'll put this behind an annotation so that it will be in effect only for containers annotated for it. And only take of the draft status once that commit is in place.

Spotted one typo in one commit message With multiple devices allocated to a since container

Thanks for spotting that! Fixed.

klihub added 6 commits July 2, 2025 09:56
Set defaults for agent config in values. This makes it easy to
enable pod resource API by passing this to helm install

   --set config.agent.podResourceAPI=true

Signed-off-by: Krisztian Litkey <[email protected]>
Allow checking if a topology hint is based on pod resource API.

Signed-off-by: Krisztian Litkey <[email protected]>
Give more priority for topology hints than earlier, putting
them right below annotated affinities. This will give hints
priority over memory pinning tightness, which is preferable
when a container allocates multiple devices with different
memory locality.

Hints now have precedence over annotated memory type. This
might be a bit questionable, since hints are implied while
memory type annotations are explicit. We probably can live
with this for the time being. Hints can be selectively dis-
abled per pod or container to restore the earlier behavior.

Signed-off-by: Krisztian Litkey <[email protected]>
If a container asks for at least as many exsclusive CPUs as it
has pod resource API hints, try allocating CPUs by hints first.

With multiple devices allocated to a single container, this can
help in cases where the collective locality of devices forces
allocation high in the pool tree, where we should prefer CPUs
with locality to one of the devices and avoid other CPUs.

For instance, devices with locality to NUMA node #0 and #3, or
'half of' sockets #0 and #1, and a request for 2 CPUs, we end
up in the root pool. But we should only prefer allocating CPUs
with locality to NUMA nodes #0 or #3 and avoiding any CPU with
locality to node #1 or #3.

Signed-off-by: Krisztian Litkey <[email protected]>
If a container has pod resource API hints, try allocating from
and pinning to memory from nodes which hints indicate locality
to.

Signed-off-by: Krisztian Litkey <[email protected]>
Only try to pick resources by hints, if a container is annotated
for it using 'pick-resources-by-hints.resource-policy.nri.io'.

Signed-off-by: Krisztian Litkey <[email protected]>
Copy link
Collaborator

@fmuyassarov fmuyassarov left a comment

Choose a reason for hiding this comment

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

If NRT is now enabled by default on the agent, I wonder if we still need the Helm based gate for toggling it. Since exposing resources via NRT seems to be the expected default (at least in Helm deployments), maybe we can simplify things by removing that extra switch, unless we're still concerned about generating large CRs? Just a thought.

@fmuyassarov
Copy link
Collaborator

but otherwise LGTM, as you already mentioned the annotation name is something that can be improved but I can't really suggest anything better since naming is always hard.

@klihub klihub force-pushed the devel/pick-resources-by-hints branch from 5b0e265 to 7ea0bb5 Compare July 2, 2025 07:54
@klihub klihub marked this pull request as ready for review July 2, 2025 07:54
@klihub
Copy link
Collaborator Author

klihub commented Jul 2, 2025

If NRT is now enabled by default on the agent, I wonder if we still need the Helm based gate for toggling it. Since exposing resources via NRT seems to be the expected default (at least in Helm deployments), maybe we can simplify things by removing that extra switch, unless we're still concerned about generating large CRs? Just a thought.

I think NRT has already been on by default in the configuration. This was just implicit by leaving it out of the default configuration in values.yaml but having it default to enabled in the configuration CRD.

Copy link
Collaborator

@fmuyassarov fmuyassarov left a comment

Choose a reason for hiding this comment

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

Thank you.

@fmuyassarov fmuyassarov merged commit 7094685 into containers:main Jul 2, 2025
9 checks passed
@klihub klihub deleted the devel/pick-resources-by-hints branch July 2, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants