Skip to content

Conversation

@kthui
Copy link
Contributor

@kthui kthui commented Jun 17, 2025

Overview:

Update the logic when filtering stale inhibited instances.

Details:

The previous instance_id is not reused when a failed worker restarts, so the updated logic will ensure the stale instance_id is removed from the hash map, to avoid it from growing linearly with respect to the number of failed workers detected.

Where should the reviewer start?

N/A

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of inhibited instances to ensure expired inhibitions are properly cleared and only valid inhibitions are retained. This results in more accurate instance availability reporting.

@kthui kthui self-assigned this Jun 17, 2025
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 17, 2025

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.

@kthui kthui changed the title Update inhibited instance removal logic refactor: Update inhibited instance removal logic Jun 17, 2025
@kthui kthui force-pushed the jacky-ft-down-instance-track branch from 89ae48b to 13051e9 Compare June 17, 2025 00:58
@kthui kthui marked this pull request as ready for review June 17, 2025 17:07
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Walkthrough

The instances_avail method in the Client struct was refactored to update the handling of inhibited instances. The process now uses a temporary map to track valid inhibitions, ensuring only current and non-stale inhibitions persist, and removes inhibitions for instances no longer present or with expired TTLs.

Changes

File Change Summary
lib/runtime/src/component/client.rs Refactored instances_avail to use a temporary map for valid inhibitions and update inhibition logic.

Poem

In the code where instances dwell,
A map of inhibitions cast its spell.
Now with care, old ghosts are swept,
Only the freshest inhibitions kept.
With a hop and a skip, the logic’s refined—
Cleaner, neater, peace of mind!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/runtime/src/component/client.rs (1)

149-155: Avoid extra allocation – use retain to filter inhibited in-place

Creating a fresh HashMap (new_inhibited) every time this code path runs forces an extra allocation and a full copy of the surviving elements. Since the lock on instance_inhibited is already held, you can safely mutate the map in-place:

-let mut new_inhibited = HashMap::<i64, u64>::new();
-let filtered = instances
-    .into_iter()
-    .filter_map(|instance| {
+// Remove entries whose instance disappeared OR TTL expired
+inhibited.retain(|id, ts| {
+    instances.iter().any(|i| i.id() == *id) && now.saturating_sub(*ts) <= ETCD_LEASE_TTL
+});
+
+let filtered = instances.into_iter().filter_map(|instance| {

This eliminates the second map and the final assignment (*inhibited = new_inhibited;) while preserving the logic.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a67e682 and 13051e9.

📒 Files selected for processing (1)
  • lib/runtime/src/component/client.rs (1 hunks)

@kthui kthui enabled auto-merge (squash) June 17, 2025 18:00
@kthui kthui requested a review from oandreeva-nv June 17, 2025 18:01
Copy link
Contributor

@oandreeva-nv oandreeva-nv left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kthui kthui merged commit 4abab20 into main Jun 17, 2025
11 checks passed
@kthui kthui deleted the jacky-ft-down-instance-track branch June 17, 2025 21:31
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.

3 participants