[core][refactor] replace unnecessary shared_ptrs with unique_ptrs and references in raylet#54062
Merged
edoakes merged 1 commit intoray-project:masterfrom Jun 25, 2025
Merged
Conversation
f48c876 to
8d3ce74
Compare
… references in raylet Signed-off-by: Rueian <rueian@anyscale.com> Signed-off-by: Rueian <rueiancsie@gmail.com>
8d3ce74 to
2ffa8f9
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR replaces unnecessary std::shared_ptr usages with std::unique_ptr and raw references in the Raylet code to improve ownership clarity and reduce overhead.
- Changed constructors and member fields to accept and store non-owning references for
gcs::GcsClientand other interfaces. - Updated all call sites in tests,
main.cc, and various Raylet modules to pass dereferenced pointers. - Adjusted the BUILD file to include the new
:ray_mocktarget and consolidatecompiler_param_filefeatures.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ray/raylet/worker_pool.h | Changed gcs_client from shared_ptr to reference |
| src/ray/raylet/worker_pool.cc | Updated initializer list and calls to use reference |
| src/ray/raylet/worker_pool_test.cc | Passed *mock_gcs_client_ into test constructor |
| src/ray/raylet/node_manager.h | Refactored numerous params and members to references |
| src/ray/raylet/node_manager.cc | Updated method bodies to use reference members |
| src/ray/raylet/raylet.h | Switched gcs_client and node_manager to references |
| src/ray/raylet/raylet.cc | Updated ctor and member access to reference style |
| src/ray/raylet/placement_group_resource_manager.{h,cc} | Changed scheduler member to reference |
| src/ray/raylet/main.cc | Switched shared_ptr to unique_ptr and passed references |
| src/ray/object_manager/ownership_object_directory.{h,cc} | Converted gcs_client fields and calls to reference |
| src/ray/object_manager/object_manager.{h,cc} | Updated gcs_client ownership to reference |
| BUILD.bazel | Added :ray_mock and consolidated compiler_param_file features |
Comments suppressed due to low confidence (2)
src/ray/raylet/worker_pool.h:324
- [nitpick] The constructor parameter
gcs_clientis now a non-owning reference; consider updating the doc comment to note that the caller must guarantee its lifetime outlives theWorkerPoolinstance.
gcs::GcsClient &gcs_client,
src/ray/raylet/node_manager.h:138
- [nitpick] Update the parameter comment for
gcs_clientto clarify that this is a non-owning reference and must remain valid for the lifetime ofNodeManager.
gcs::GcsClient &gcs_client,
Collaborator
|
amazing, thanks @rueian |
8 tasks
minerharry
pushed a commit
to minerharry/ray
that referenced
this pull request
Jun 27, 2025
… references in raylet (ray-project#54062) Following the suggestion in ray-project#53782 (comment), this PR replace all unnecessary shared_ptrs with unique_ptrs and references in Raylet. Signed-off-by: Rueian <rueian@anyscale.com> Signed-off-by: Rueian <rueiancsie@gmail.com>
elliot-barn
pushed a commit
that referenced
this pull request
Jul 2, 2025
… references in raylet (#54062) Following the suggestion in #53782 (comment), this PR replace all unnecessary shared_ptrs with unique_ptrs and references in Raylet. Signed-off-by: Rueian <rueian@anyscale.com> Signed-off-by: Rueian <rueiancsie@gmail.com> Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Following the suggestion in #53782 (comment), this PR replace all unnecessary shared_ptrs with unique_ptrs and references in Raylet.
Hi @dayshah,
Could you take a look? Thanks!
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.