Skip to content

[Performance]: Use a cache for PodTemplateHash and optimize calls to CreateOrUpdate#439

Draft
unmarshall wants to merge 5 commits intoai-dynamo:mainfrom
unmarshall:hashcache
Draft

[Performance]: Use a cache for PodTemplateHash and optimize calls to CreateOrUpdate#439
unmarshall wants to merge 5 commits intoai-dynamo:mainfrom
unmarshall:hashcache

Conversation

@unmarshall
Copy link
Collaborator

What type of PR is this?

/kind enhancement
/area performance

What this PR does / why we need it:

  • Introduces a LRU cache with bounded items to store computed PodSpec hash.
  • Adapted all reconcilers to use the cache instead always computing the cache even if there was no change in PodSpec.
  • Removed the use of dump.ForHash and replaced it with simple JSON serialization. Added benchmark tests to prove that dump.ForHash is quite slow/expensive w.r.t CPU usage.
  • Optimizes calls to controller-runtime CreateOrUpdate since that uses too many DeepCopy calls making it a bit expensive.

Which issue(s) this PR fixes:

Fixes #406 and partially addresses #407

Special notes for your reviewer:

Does this PR introduce a API change?

Reduced CPU usage in reconcilers by optimizing PodSpec hash computation.

Additional documentation e.g., enhancement proposals, usage docs, etc.:


* Introduced LRU cache for PodTemplateSpec hashes.
* Added utility functions to compute Hash.
* Replaced dump.ForHash with JSON marshaling.
* Added benchmark tests to different hash computing options to compare.
* Adapted Pod component in PCLQ reconciler to use the hash cache.
* Adapted PCLQ reconcile status to use the hash cache.
* Adapted PCLQ component in PCS reconciler to pre-compute hashes via the
  hash cache and optimize the calls for CreateOrPatch.
* Adapted PCSG status reconciliation to optimize hash computation via
  hash cache.

Signed-off-by: Madhav Bhargava <madhav.bhargava@sap.com>
Signed-off-by: Madhav Bhargava <madhav.bhargava@sap.com>
Signed-off-by: Madhav Bhargava <madhav.bhargava@sap.com>
Signed-off-by: Madhav Bhargava <madhav.bhargava@sap.com>
@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 17, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@unmarshall unmarshall marked this pull request as draft February 17, 2026 14:22
Signed-off-by: Madhav Bhargava <madhav.bhargava@sap.com>
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.

Computation of PodTemplateSpec has is CPU intensive

1 participant