Skip to content

Conversation

@kingeasternsun
Copy link
Contributor

What type of PR is this?

/kind improvement

What this PR does / why we need it:

This PR optimizes the resource update mechanism for ancestor queues in hierarchical queue structures within the capacity plugin.

Optimization Details:

  • Instead of recalculating all ancestor queue resources from scratch, this implementation calculates the resource deltas (differences) once for each job update
  • The deltas are then efficiently propagated to all ancestor queues in the hierarchy
  • This approach reduces computational overhead, especially in deep hierarchical queue structures with multiple ancestors

Performance Benefits:

  • Reduces redundant calculations when updating ancestor queue resources
  • Improves scheduler performance when dealing with hierarchical queues
  • Scales better with deeper queue hierarchies

The optimization applies to four resource metrics:

  • allocated: Resources currently allocated to pods
  • request: Total resources requested
  • inqueue: Resources waiting in queue
  • elastic: Elastic resources available

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

  • The logic preserves the same behavior as before, only optimizing the calculation method
  • Old values are cloned at the beginning (lines 544-547) to calculate accurate deltas
  • The delta propagation loop (lines 581-587) efficiently updates all ancestors

Does this PR introduce a user-facing change?

NONE

opt
Signed-off-by: wangdongyang1 <[email protected]>
@volcano-sh-bot
Copy link
Contributor

@kingeasternsun: The label(s) kind/improvement cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

/kind improvement

What this PR does / why we need it:

This PR optimizes the resource update mechanism for ancestor queues in hierarchical queue structures within the capacity plugin.

Optimization Details:

  • Instead of recalculating all ancestor queue resources from scratch, this implementation calculates the resource deltas (differences) once for each job update
  • The deltas are then efficiently propagated to all ancestor queues in the hierarchy
  • This approach reduces computational overhead, especially in deep hierarchical queue structures with multiple ancestors

Performance Benefits:

  • Reduces redundant calculations when updating ancestor queue resources
  • Improves scheduler performance when dealing with hierarchical queues
  • Scales better with deeper queue hierarchies

The optimization applies to four resource metrics:

  • allocated: Resources currently allocated to pods
  • request: Total resources requested
  • inqueue: Resources waiting in queue
  • elastic: Elastic resources available

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

  • The logic preserves the same behavior as before, only optimizing the calculation method
  • Old values are cloned at the beginning (lines 544-547) to calculate accurate deltas
  • The delta propagation loop (lines 581-587) efficiently updates all ancestors

Does this PR introduce a user-facing change?

NONE

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kingeasternsun, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to enhance the performance of the scheduler's capacity plugin by optimizing how resource updates are handled for hierarchical queues. By implementing a delta propagation mechanism, the system avoids costly full recalculations of ancestor queue resources, leading to more efficient updates and improved scalability, particularly in complex queue hierarchies. This change is designed to maintain existing functional behavior while significantly boosting computational efficiency.

Highlights

  • Performance Optimization: The pull request introduces an optimization to the resource update mechanism for ancestor queues within the capacity plugin, specifically for hierarchical queue structures.
  • Delta Propagation: Instead of recalculating all ancestor queue resources from scratch, the system now calculates resource deltas (differences) once per job update and propagates these deltas efficiently to all ancestor queues.
  • Reduced Overhead: This approach significantly reduces computational overhead, especially in deep hierarchical queue structures, by avoiding redundant calculations.
  • Affected Metrics: The optimization applies to four key resource metrics: 'allocated', 'request', 'inqueue', and 'elastic'.
  • Behavior Preservation: The core logic and behavior remain unchanged; only the method of calculation has been optimized for efficiency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@volcano-sh-bot volcano-sh-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 4, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valid optimization to the capacity plugin by pre-calculating resource deltas for ancestor queues. This change effectively reduces redundant computations within the loop, improving performance, especially in deep hierarchical queue structures. The implementation is correct and follows the intended logic. However, there's a subtle issue with the re-use of delta variables which could lead to bugs if the Add method's contract changes in the future. I've added a comment with a suggestion to make the code more robust against such changes.

@hajnalmt
Copy link
Contributor

hajnalmt commented Nov 6, 2025

/lgtm
nice improvement

@hajnalmt
Copy link
Contributor

hajnalmt commented Jan 9, 2026

/cc @JesseStutler

@JesseStutler
Copy link
Member

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JesseStutler

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

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 15, 2026
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants