-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[core] Minor cpp changes around core worker #48262
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
Changes from 15 commits
0048901
34c8be3
67ff6fc
bf649c9
b88c105
7ff72eb
1293f86
24f0635
877242b
34f8199
b667628
d2c3259
5314b2f
a863ecc
869327e
28a8f25
5e089b9
9f8655a
0bcb639
f459cf6
085621c
15afd22
aae4aa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4036,7 +4036,7 @@ void CoreWorker::HandleCancelTask(rpc::CancelTaskRequest request, | |
| RAY_LOG(INFO).WithField(task_id).WithField(current_actor_id) | ||
| << "Cancel an actor task"; | ||
| CancelActorTaskOnExecutor( | ||
| caller_worker_id, task_id, force_kill, recursive, on_cancel_callback); | ||
| caller_worker_id, task_id, force_kill, recursive, std::move(on_cancel_callback)); | ||
|
Contributor
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. Do we need to move since the parameter is const &?
Contributor
Author
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. ya, my bad left it in even after changing param
Contributor
Author
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. wait actually CancelActorTaskOnExecucutor takes by value, CancelTaskOnExecutor takes by const ref |
||
| } else { | ||
| RAY_CHECK(current_actor_id.IsNil()); | ||
| RAY_LOG(INFO).WithField(task_id) << "Cancel a normal task"; | ||
|
|
@@ -4047,7 +4047,7 @@ void CoreWorker::HandleCancelTask(rpc::CancelTaskRequest request, | |
| void CoreWorker::CancelTaskOnExecutor(TaskID task_id, | ||
| bool force_kill, | ||
| bool recursive, | ||
| OnCanceledCallback on_canceled) { | ||
| const OnCanceledCallback &on_canceled) { | ||
| bool requested_task_running; | ||
| { | ||
| absl::MutexLock lock(&mutex_); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,7 @@ bool GetRequest::Wait(int64_t timeout_ms) { | |
| auto remaining_timeout_ms = timeout_ms; | ||
| auto timeout_timestamp = current_time_ms() + timeout_ms; | ||
| while (!is_ready_) { | ||
| // TODO (dayshah): see if using cv condition function instead of busy while helps. | ||
|
Contributor
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. is this still relevant?
Contributor
Author
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. ya i think it could still be relevant, pretty sure using
Contributor
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. ok, let's do it in another PR, if needed |
||
| auto status = cv_.wait_for(lock, std::chrono::milliseconds(remaining_timeout_ms)); | ||
| auto current_timestamp = current_time_ms(); | ||
| remaining_timeout_ms = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,6 @@ | |
|
|
||
| #include "ray/common/buffer.h" | ||
| #include "ray/common/common_protocol.h" | ||
| #include "ray/common/constants.h" | ||
| #include "ray/core_worker/common.h" | ||
| #include "ray/gcs/pb_util.h" | ||
| #include "ray/util/exponential_backoff.h" | ||
| #include "ray/util/util.h" | ||
|
|
@@ -26,10 +24,10 @@ namespace ray { | |
| namespace core { | ||
|
|
||
| // Start throttling task failure logs once we hit this threshold. | ||
| const int64_t kTaskFailureThrottlingThreshold = 50; | ||
| constexpr int64_t kTaskFailureThrottlingThreshold = 50; | ||
|
|
||
| // Throttle task failure logs to once this interval. | ||
| const int64_t kTaskFailureLoggingFrequencyMillis = 5000; | ||
| constexpr int64_t kTaskFailureLoggingFrequencyMillis = 5000; | ||
|
|
||
| absl::flat_hash_set<ObjectID> ObjectRefStream::GetItemsUnconsumed() const { | ||
| absl::flat_hash_set<ObjectID> result; | ||
|
|
@@ -237,7 +235,9 @@ std::vector<rpc::ObjectReference> TaskManager::AddPendingTask( | |
| // Add new owned objects for the return values of the task. | ||
| size_t num_returns = spec.NumReturns(); | ||
| std::vector<rpc::ObjectReference> returned_refs; | ||
| returned_refs.reserve(num_returns); | ||
| std::vector<ObjectID> return_ids; | ||
| return_ids.reserve(num_returns); | ||
| for (size_t i = 0; i < num_returns; i++) { | ||
| auto return_id = spec.ReturnId(i); | ||
| if (!spec.IsActorCreationTask()) { | ||
|
|
@@ -252,7 +252,7 @@ std::vector<rpc::ObjectReference> TaskManager::AddPendingTask( | |
| // language frontend. Note that the language bindings should set | ||
| // skip_adding_local_ref=True to avoid double referencing the object. | ||
| reference_counter_->AddOwnedObject(return_id, | ||
| /*inner_ids=*/{}, | ||
| /*contained_ids=*/{}, | ||
| caller_address, | ||
| call_site, | ||
| -1, | ||
|
|
@@ -707,7 +707,7 @@ bool TaskManager::HandleReportGeneratorItemReturns( | |
| HandleTaskReturn(object_id, | ||
| return_object, | ||
| NodeID::FromBinary(request.worker_addr().raylet_id()), | ||
| /*store_in_plasma*/ store_in_plasma_ids.count(object_id)); | ||
| /*store_in_plasma=*/store_in_plasma_ids.contains(object_id)); | ||
| } | ||
|
|
||
| // Handle backpressure if needed. | ||
|
|
@@ -807,7 +807,7 @@ void TaskManager::CompletePendingTask(const TaskID &task_id, | |
| if (HandleTaskReturn(object_id, | ||
| return_object, | ||
| NodeID::FromBinary(worker_addr.raylet_id()), | ||
| store_in_plasma_ids.count(object_id))) { | ||
| store_in_plasma_ids.contains(object_id))) { | ||
| direct_return_ids.push_back(object_id); | ||
| } | ||
| } | ||
|
|
@@ -933,7 +933,7 @@ void TaskManager::CompletePendingTask(const TaskID &task_id, | |
| HandleTaskReturn(generator_return_id, | ||
| return_object, | ||
| NodeID::FromBinary(worker_addr.raylet_id()), | ||
| store_in_plasma_ids.count(generator_return_id)); | ||
| store_in_plasma_ids.contains(generator_return_id)); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1043,22 +1043,27 @@ void TaskManager::FailPendingTask(const TaskID &task_id, | |
| auto it = submissible_tasks_.find(task_id); | ||
| RAY_CHECK(it != submissible_tasks_.end()) | ||
| << "Tried to fail task that was not pending " << task_id; | ||
| RAY_CHECK(it->second.IsPending()) | ||
|
Contributor
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. why changing this? The function name indicating that it's a pending task.
Contributor
Author
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. So the issue was there was a ray data backpressure test and a train test that failed here, it seems that the task cancel would happen after the task finishes and by the time it acquires that mutex in FailPendingTask it's already at a point where the task status is finished. So change here is basically just to no-op on if the task is finished at this point. and IsPending checks for status != fail and finish, only want to check for fail here to make sure we're not double failing |
||
| << "Tried to fail task that was not pending " << task_id; | ||
| // task was finished by the time it got to cancelling here | ||
| if (it->second.GetStatus() == rpc::TaskStatus::FINISHED) { | ||
| submissible_tasks_.erase(it); | ||
| return; | ||
| } | ||
| RAY_CHECK(it->second.GetStatus() != rpc::TaskStatus::FAILED) | ||
| << "Tried to fail task that was already failed " << task_id; | ||
| spec = it->second.spec; | ||
|
|
||
| if (status && status->IsIntentionalSystemExit()) { | ||
| if ((status != nullptr) && status->IsIntentionalSystemExit()) { | ||
| // We don't mark intentional system exit as failures, such as tasks that | ||
| // exit by exit_actor(), exit by ray.shutdown(), etc. These tasks are expected | ||
| // to exit and not be marked as failure. | ||
| SetTaskStatus(it->second, rpc::TaskStatus::FINISHED); | ||
| } else { | ||
| SetTaskStatus( | ||
| it->second, | ||
| rpc::TaskStatus::FAILED, | ||
| (ray_error_info == nullptr | ||
| ? gcs::GetRayErrorInfo(error_type, (status ? status->ToString() : "")) | ||
| : *ray_error_info)); | ||
| SetTaskStatus(it->second, | ||
| rpc::TaskStatus::FAILED, | ||
| (ray_error_info == nullptr | ||
| ? gcs::GetRayErrorInfo( | ||
| error_type, (status != nullptr ? status->ToString() : "")) | ||
| : *ray_error_info)); | ||
| } | ||
| submissible_tasks_.erase(it); | ||
| num_pending_tasks_--; | ||
|
|
@@ -1308,15 +1313,15 @@ void TaskManager::MarkTaskReturnObjectsFailed( | |
| int64_t num_returns = spec.NumReturns(); | ||
| for (int i = 0; i < num_returns; i++) { | ||
| const auto object_id = ObjectID::FromIndex(task_id, /*index=*/i + 1); | ||
| if (store_in_plasma_ids.count(object_id)) { | ||
| if (store_in_plasma_ids.contains(object_id)) { | ||
| put_in_local_plasma_callback_(error, object_id); | ||
| } else { | ||
| in_memory_store_->Put(error, object_id); | ||
| } | ||
| } | ||
| if (spec.ReturnsDynamic()) { | ||
| for (const auto &dynamic_return_id : spec.DynamicReturnIds()) { | ||
| if (store_in_plasma_ids.count(dynamic_return_id)) { | ||
| if (store_in_plasma_ids.contains(dynamic_return_id)) { | ||
| put_in_local_plasma_callback_(error, dynamic_return_id); | ||
| } else { | ||
| in_memory_store_->Put(error, dynamic_return_id); | ||
|
|
@@ -1341,7 +1346,7 @@ void TaskManager::MarkTaskReturnObjectsFailed( | |
| auto num_streaming_generator_returns = spec.NumStreamingGeneratorReturns(); | ||
| for (size_t i = 0; i < num_streaming_generator_returns; i++) { | ||
| const auto generator_return_id = spec.StreamingGeneratorReturnId(i); | ||
| if (store_in_plasma_ids.count(generator_return_id)) { | ||
| if (store_in_plasma_ids.contains(generator_return_id)) { | ||
| put_in_local_plasma_callback_(error, generator_return_id); | ||
| } else { | ||
| in_memory_store_->Put(error, generator_return_id); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.