Skip to content

Conversation

@handan-yxh
Copy link
Contributor

What type of PR is this?

doc

What this PR does / why we need it:

Add scheduler cache and snapshot design
Proposal details: https://docs.google.com/document/d/1NDTEGulhQ__sdZ_c2kN3ojtJIZie5O7_GyZyKIOLz-g/edit?tab=t.3q3qlfh4r4sf#heading=h.9r4wotc3nl4d

Which issue(s) this PR fixes:

Fixes #4722

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

@gemini-code-assist
Copy link

Summary of Changes

Hello @handan-yxh, 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 introduces comprehensive documentation for the Agent scheduler's cache and snapshot design. The update details significant optimizations aimed at enhancing scheduling throughput and concurrency, including advanced data structures and mechanisms for efficient, incremental updates and parallel processing across multiple workers.

Highlights

  • Scheduler Cache and Snapshot Design: Detailed documentation has been added for the Agent scheduler's cache and snapshot mechanisms, outlining the design for improved performance.
  • Optimized Snapshot Maintenance: The design now includes strategies for improving scheduling throughput, such as generation-based incremental updates, which process only changed nodes.
  • Efficient Data Structures: The documentation explains the use of dual data structures, combining a doubly linked list for recency order and a hash map for O(1) lookups, along with indexed snapshots.
  • Concurrent Access Support: The design details read-write lock separation to enable multiple workers to concurrently access and update their independent snapshots, enhancing parallel processing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 22, 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 adds valuable documentation for the scheduler cache and snapshot design, replacing the 'TBD' section with a clear and detailed explanation of the optimizations. The new content is well-structured and informative. My review includes a couple of minor formatting suggestions to improve readability.

Design of snapshot fast update mechanism and why.
TBD
To improve the overall scheduling throughput of the Agent scheduler, we optimized the Cache and Snapshot data structures and algorithms.
1. **Generation-based Incremental Updates**: Each node in the cache maintains a monotonically increasing generation number. When a node's state changes (pod addition/removal, resource updates), its generation is incremented and the node is moved to the head of a doubly linked list. During snapshot updates, only nodes with generation numbers greater than the snapshot's current generation are processed.Significantly reduces the number of nodes that need to be processed for each update.

Choose a reason for hiding this comment

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

medium

There appears to be a missing space after the period, which affects readability. Please add a space between the sentences.

Suggested change
1. **Generation-based Incremental Updates**: Each node in the cache maintains a monotonically increasing generation number. When a node's state changes (pod addition/removal, resource updates), its generation is incremented and the node is moved to the head of a doubly linked list. During snapshot updates, only nodes with generation numbers greater than the snapshot's current generation are processed.Significantly reduces the number of nodes that need to be processed for each update.
1. **Generation-based Incremental Updates**: Each node in the cache maintains a monotonically increasing generation number. When a node's state changes (pod addition/removal, resource updates), its generation is incremented and the node is moved to the head of a doubly linked list. During snapshot updates, only nodes with generation numbers greater than the snapshot's current generation are processed. Significantly reduces the number of nodes that need to be processed for each update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll fix it.

- Doubly Linked List: Maintains nodes in recency order (most recently updated at head).
- Hash Map: Provides O(1) node lookup by name.
- Indexed Snapshot: Snapshot maintains maps for quick node position lookup.
3. **Concurrent Access Support**: The read-write lock separation design supports multiple workers concurrently accessing and updating their individual snapshots. Each worker maintains an independent snapshot instance, avoiding contention during scheduling cycles.Significantly improves concurrency performance in multithreaded scenarios.

Choose a reason for hiding this comment

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

medium

There appears to be a missing space after the period, which affects readability. Please add a space between the sentences.

Suggested change
3. **Concurrent Access Support**: The read-write lock separation design supports multiple workers concurrently accessing and updating their individual snapshots. Each worker maintains an independent snapshot instance, avoiding contention during scheduling cycles.Significantly improves concurrency performance in multithreaded scenarios.
3. **Concurrent Access Support**: The read-write lock separation design supports multiple workers concurrently accessing and updating their individual snapshots. Each worker maintains an independent snapshot instance, avoiding contention during scheduling cycles. Significantly improves concurrency performance in multithreaded scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll fix it.

## Snapshot maintenance
Design of snapshot fast update mechanism and why.
TBD
To improve the overall scheduling throughput of the Agent scheduler, we optimized the Cache and Snapshot data structures and algorithms.
Copy link
Contributor

Choose a reason for hiding this comment

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

add some background about the purpose of snapshot and relationships between snapshot and nodes in cache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some background information has been added.

## Snapshot maintenance
Design of snapshot fast update mechanism and why.
TBD
To improve the overall scheduling throughput of the Agent scheduler, we optimized the Cache and Snapshot data structures and algorithms.
Copy link
Member

Choose a reason for hiding this comment

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

Prefer more information about how the snapshot lifecycle is managed, such as when snapshots are created, updated and deleted, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some text has been added, and simple diagrams will be used to describe the lifecycle more clearly.

Design of snapshot fast update mechanism and why.
TBD
To improve the overall scheduling throughput of the Agent scheduler, we optimized the Cache and Snapshot data structures and algorithms.
1. **Generation-based Incremental Updates**: Each node in the cache maintains a monotonically increasing generation number. When a node's state changes (pod addition/removal, resource updates), its generation is incremented and the node is moved to the head of a doubly linked list. During snapshot updates, only nodes with generation numbers greater than the snapshot's current generation are processed.Significantly reduces the number of nodes that need to be processed for each update.
Copy link
Member

Choose a reason for hiding this comment

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

For the processing logic of the incremental update here, it would be better to have a simple schematic diagram.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I will add a diagram.

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kevin-wangzefeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@handan-yxh handan-yxh force-pushed the doc/agent-scheduler-snapshot-design branch from 80ee99b to 79bce58 Compare December 29, 2025 09:48
@volcano-sh-bot volcano-sh-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed do-not-merge/contains-merge-commits size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 29, 2025
@handan-yxh handan-yxh force-pushed the doc/agent-scheduler-snapshot-design branch from 79bce58 to 18a891c Compare December 29, 2025 10:16
@qi-min
Copy link
Contributor

qi-min commented Dec 30, 2025

/retest

@volcano-sh-bot
Copy link
Contributor

@qi-min: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@JesseStutler
Copy link
Member

/retest

@handan-yxh handan-yxh force-pushed the doc/agent-scheduler-snapshot-design branch from 18a891c to efc0e62 Compare December 31, 2025 08:19
@handan-yxh handan-yxh force-pushed the doc/agent-scheduler-snapshot-design branch from efc0e62 to edbea94 Compare December 31, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[Enhancement] Support fast scheduling for AI Agent Workloads

6 participants