-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[core] Fix gcs server using shared pointer #48888
Merged
aslonnie
merged 4 commits into
ray-project:master
from
dentiny:hjiang/fix-gcs-server-shared-pointer
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
|
||
#include "ray/gcs/gcs_server/gcs_placement_group_manager.h" | ||
|
||
#include <utility> | ||
|
||
#include "ray/common/asio/asio_util.h" | ||
#include "ray/common/asio/instrumented_io_context.h" | ||
#include "ray/common/ray_config.h" | ||
|
@@ -181,15 +183,15 @@ rpc::PlacementGroupStats *GcsPlacementGroup::GetMutableStats() { | |
|
||
GcsPlacementGroupManager::GcsPlacementGroupManager( | ||
instrumented_io_context &io_context, | ||
std::shared_ptr<GcsPlacementGroupSchedulerInterface> scheduler, | ||
GcsPlacementGroupSchedulerInterface *scheduler, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is never nullptr, so use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, we have places passing in nullptr. |
||
std::shared_ptr<gcs::GcsTableStorage> gcs_table_storage, | ||
GcsResourceManager &gcs_resource_manager, | ||
std::function<std::string(const JobID &)> get_ray_namespace) | ||
: io_context_(io_context), | ||
gcs_placement_group_scheduler_(std::move(scheduler)), | ||
gcs_placement_group_scheduler_(scheduler), | ||
gcs_table_storage_(std::move(gcs_table_storage)), | ||
gcs_resource_manager_(gcs_resource_manager), | ||
get_ray_namespace_(get_ray_namespace) { | ||
get_ray_namespace_(std::move(get_ray_namespace)) { | ||
placement_group_state_counter_.reset( | ||
new CounterMap<rpc::PlacementGroupTableData::PlacementGroupState>()); | ||
placement_group_state_counter_->SetOnChangeCallback( | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never nullptr, so use
&
, not*
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik most style guides suggest pointers over references because of flexibility, moving, copying, it doesn't apply to this, but not bad to be consistent, but can we do absl::NotNull, I don't remember if we need cpp upgrade or absl upgrade for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for using reference if it's guaranteed to be not null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO our use case here does not require flexibility or so: we won't reassign, copy or move them. I'd say we like the fact that it can't (easiliy) be moved by using reference. The only caution is that we need to make sure the references must outlive the objects holding those refs, which is the case since all these classes share a lifetime with a GcsServer (up until a reset call).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have use cases passing nullptr:
ray/src/ray/gcs/gcs_server/test/gcs_actor_scheduler_mock_test.cc
Lines 41 to 42 in ba8674a