Skip to content

[core] Miscellaneous cleanup around storing task outputs #54908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 29, 2025

Conversation

dayshah
Copy link
Contributor

@dayshah dayshah commented Jul 24, 2025

Why are these changes needed?

Just some cleaning up some code that annoyed me while I was looking through code for #54904. There's no actual functional changes here.

Some of the bigger changes are:

  • Adding a RAY_CHECK_OK in task_receiver, based on the code, the return status can only be ok or one of those 3 in the if or ok. Enforcing this here makes life easier people who are reading this code in the future. It was already enforced in CoreWorker::ExecuteTask which is where the task_receiver gets this status from anyways. In my ideal world, we would be returning a more constrained enum and not ray status so this check wouldn't even be necessary.
  • inlining RetryCreate and deleting it
  • inlining the statuses that ShouldExitWorker is checking for to make it clearer

dayshah added 4 commits July 23, 2025 20:49
Signed-off-by: dayshah <[email protected]>
Signed-off-by: dayshah <[email protected]>
Signed-off-by: dayshah <[email protected]>
@dayshah dayshah added the go add ONLY when ready to merge, run all tests label Jul 24, 2025
Copy link
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.

Summary of Changes

Hello @dayshah, 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 a series of targeted code cleanups and refactorings within Ray's core components, primarily affecting how task outputs are handled and how worker exit conditions are managed. The changes aim to enhance code readability, improve maintainability, and introduce more robust checks, contributing to a cleaner and more explicit codebase.

Highlights

  • Code Clarity & Maintainability: I've inlined the logic for ShouldExitWorker directly into the TaskReceiver to make the worker exit conditions explicit and easier to understand, removing the need for a separate helper method.
  • Refactoring & Simplification: The RetryCreate helper method in the Plasma client has been eliminated by inlining its functionality into CreateAndSpillIfNeeded, which reduces indirection and simplifies the object creation retry mechanism.
  • Robustness: I've added a RAY_CHECK_OK assertion in the TaskReceiver to enforce that the status of task execution is OK when objects are valid, improving code correctness and making assumptions explicit.
  • Modern C++ Practices: Various C++ modernizations have been applied, including using std::move for efficient resource transfer, std::make_unique for safer smart pointer creation, std::map::contains for clearer map lookups, and explicit nullptr checks for improved code safety and readability.
  • Cython Workaround Removal: A specific workaround in the Cython _raylet.pyx file related to reference assignment has been removed, simplifying the code where ray_error_to_memory_buf is used.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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.

Copy link
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 provides a great set of miscellaneous cleanups that improve code quality and clarity. The changes, such as inlining RetryCreate and ShouldExitWorker, using modern C++ features like std::move and nullptr, and adding defensive checks, are all positive. The code looks good, and I don't have any concerns.

dayshah added 2 commits July 25, 2025 22:45
Signed-off-by: dayshah <[email protected]>
Signed-off-by: dayshah <[email protected]>
@dayshah dayshah marked this pull request as ready for review July 26, 2025 18:15
@dayshah dayshah requested a review from a team as a code owner July 26, 2025 18:16
Signed-off-by: dayshah <[email protected]>
@dayshah dayshah force-pushed the objects-valid-cleanup branch from 9c0dde7 to e202cc0 Compare July 27, 2025 23:47
Signed-off-by: dayshah <[email protected]>
@@ -490,6 +490,7 @@ service NodeManagerService {
returns (RegisterMutableObjectReply);
// Failure: TODO: Handle network failure for cgraphs.
rpc PushMutableObject(PushMutableObjectRequest) returns (PushMutableObjectReply);
// Failure: Uses retryable grpc client for retries.
// Failure: Is currently only used when grpc channel is unavailable for retryable core
// worker clients. The unavailable callback will eventually be retried so if this fails.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated, but just updating to be correct.

Copy link
Collaborator

@jjyao jjyao left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

} else {
RAY_LOG(FATAL) << "GPU library is not enabled.";
}
physical_buf = wrap_buffer(object_ids[i], physical_buf);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line is no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya wrap_buffer was just creating the PlasmaBuffer, before it was like 3 separate statements

  1. declare Buffer
  2. Create SharedMemoryBuffer
  3. Create PlasmaBuffer from SharedMemoryBuffer

all just one statement now

Signed-off-by: dayshah <[email protected]>
@dayshah
Copy link
Contributor Author

dayshah commented Jul 28, 2025

Nice cleanup!

updated all the ray_check's in client.cc to use the comparator checks if possible

@dayshah dayshah requested a review from jjyao July 28, 2025 17:13
Copy link
Collaborator

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

🚢

@dayshah dayshah enabled auto-merge (squash) July 28, 2025 23:01
@dayshah dayshah merged commit c041e83 into ray-project:master Jul 29, 2025
6 checks passed
@dayshah dayshah deleted the objects-valid-cleanup branch July 29, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants