Skip to content

Fix: optimize nodelock scalability with exponential backoff and listers#1663

Merged
FouoF merged 1 commit intoProject-HAMi:masterfrom
maishivamhoo123:fix/nodelock-scalability
Feb 25, 2026
Merged

Fix: optimize nodelock scalability with exponential backoff and listers#1663
FouoF merged 1 commit intoProject-HAMi:masterfrom
maishivamhoo123:fix/nodelock-scalability

Conversation

@maishivamhoo123
Copy link
Copy Markdown
Member

What type of PR is this?
/kind feature

What this PR does / why we need it:
Optimizes node locking to handle high concurrency.

  1. Implements exponential backoff in nodelock to stop retry storms.
  2. Uses Informer cache instead of direct API calls in scheduler Bind() to reduce API load.

Which issue(s) this PR fixes:
Fixes #1655

@hami-robot hami-robot Bot requested review from FouoF and archlitchi February 17, 2026 13:32
@github-actions github-actions Bot added kind/bug Something isn't working and removed kind/feature new function labels Feb 17, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @maishivamhoo123, 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 focuses on enhancing the scalability and performance of the system by addressing potential bottlenecks in node locking and scheduler operations. By introducing exponential backoff for retries and leveraging cached data for resource lookups, the changes aim to improve resilience and reduce the load on the Kubernetes API server, particularly in high-concurrency environments.

Highlights

  • Nodelock Scalability: Implemented exponential backoff in the nodelock utility to prevent retry storms and improve scalability under high concurrency.
  • Scheduler Performance: Optimized the scheduler's Bind() function to use Informer caches (listers) for retrieving Pod and Node information, reducing direct API calls and API server load.

🧠 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.

Changelog
  • pkg/scheduler/scheduler.go
    • Replaced direct kubeClient.CoreV1().Pods().Get() with s.podLister.Pods().Get() for pod retrieval.
    • Replaced direct kubeClient.CoreV1().Nodes().Get() with s.nodeLister.Get() for node retrieval.
    • Updated error messages to reflect retrieval from cache.
  • pkg/scheduler/scheduler_test.go
    • Removed sync package import.
    • Refactored Test_ListNodes_Concurrent to use a done channel instead of sync.WaitGroup for goroutine synchronization.
    • Removed comments related to concurrent map iteration panic.
  • pkg/util/nodelock/nodelock.go
    • Modified DefaultStrategy backoff Factor from 1.0 to 2.0.
    • Modified DefaultStrategy backoff Jitter from 0.1 to 0.5.
  • pkg/util/nodelock/nodelock_test.go
    • Added context and metav1 imports.
    • Introduced TestSimulateRetryStorm to verify the exponential backoff strategy's effectiveness in spreading load and preventing excessive collisions.
Activity
  • No human activity has occurred on this pull request yet.
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.

@hami-robot hami-robot Bot added the size/M label Feb 17, 2026
Copy link
Copy Markdown
Contributor

@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 significant optimizations to improve scalability and reduce API server load. The switch to using informer caches (podLister and nodeLister) in the Bind function is a great improvement that will reduce direct calls to the Kubernetes API. Additionally, implementing exponential backoff with increased jitter for the node lock retry strategy is a solid approach to mitigate contention and prevent retry storms under high concurrency. The changes are well-implemented and include a valuable new test to validate the effectiveness of the backoff strategy. Overall, this is a high-quality contribution that enhances the scheduler's performance and robustness.

Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/scheduler/scheduler.go 0.00% 4 Missing ⚠️
Flag Coverage Δ
unittests 51.58% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/util/nodelock/nodelock.go 62.87% <ø> (ø)
pkg/scheduler/scheduler.go 45.02% <0.00%> (+0.43%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maishivamhoo123
Copy link
Copy Markdown
Member Author

@archlitchi and @FouoF can you please review this PR?
Thank You.

@archlitchi
Copy link
Copy Markdown
Member

archlitchi commented Feb 24, 2026

CC @FouoF @Shouren

Have you tested on your environment?

@FouoF
Copy link
Copy Markdown
Contributor

FouoF commented Feb 24, 2026

/lgtm
As @shizheng163 described in #1655, this is a minimal optimization and it is lgtm

@FouoF
Copy link
Copy Markdown
Contributor

FouoF commented Feb 25, 2026

/lgtm

@hami-robot hami-robot Bot added the lgtm label Feb 25, 2026
@hami-robot hami-robot Bot added the approved label Feb 25, 2026
Copy link
Copy Markdown
Member

@Shouren Shouren left a comment

Choose a reason for hiding this comment

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

/lgtm

@hami-robot
Copy link
Copy Markdown
Contributor

hami-robot Bot commented Feb 25, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FouoF, maishivamhoo123, Shouren

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

@FouoF FouoF merged commit cb077d5 into Project-HAMi:master Feb 25, 2026
11 of 13 checks passed
@maishivamhoo123 maishivamhoo123 deleted the fix/nodelock-scalability branch February 25, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node Lock Scalability Issues Under High Concurrent vGPU Requests

4 participants