Skip to content

[Core] Remove ineffectual TODO comment #54464

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

owenowenisme
Copy link
Contributor

Why are these changes needed?

The TODO comment is outdated (I suppose), it says that we use a map to store TaskId <-> Work to avoid iterate through queue.

However, even if we have a map that does this, we still need to remove the element from tasks_to_schedule_ and infeasible_tasks_ queues, so we still need to iterate through them.

Therefore, we won't benefit from this.

bool ClusterTaskManager::CancelTasks(
std::function<bool(const std::shared_ptr<internal::Work> &)> predicate,
rpc::RequestWorkerLeaseReply::SchedulingFailureType failure_type,
const std::string &scheduling_failure_message) {
bool tasks_cancelled = false;
ray::erase_if<SchedulingClass, std::shared_ptr<internal::Work>>(
tasks_to_schedule_, [&](const std::shared_ptr<internal::Work> &work) {
if (predicate(work)) {
RAY_LOG(DEBUG) << "Canceling task "
<< work->task.GetTaskSpecification().TaskId()
<< " from schedule queue.";
ReplyCancelled(*work, failure_type, scheduling_failure_message);
tasks_cancelled = true;
return true;
} else {
return false;
}
});
ray::erase_if<SchedulingClass, std::shared_ptr<internal::Work>>(
infeasible_tasks_, [&](const std::shared_ptr<internal::Work> &work) {
if (predicate(work)) {
RAY_LOG(DEBUG) << "Canceling task "
<< work->task.GetTaskSpecification().TaskId()
<< " from infeasible queue.";
ReplyCancelled(*work, failure_type, scheduling_failure_message);
tasks_cancelled = true;
return true;
} else {
return false;
}
});

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: You-Cheng Lin (Owen) <mses010108@gmail.com>
@Copilot Copilot AI review requested due to automatic review settings July 9, 2025 07:51
Copy link
Contributor

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Removes an outdated TODO that suggested indexing TaskID to Work for cancellation, which no longer provides benefit since queue iteration is still required.

  • Deleted a two-line outdated comment in cluster_task_manager.h

@owenowenisme owenowenisme changed the title [Core] Remove un [Core] Remove ineffectual TODO comment Jul 9, 2025
@cszhu cszhu added community-contribution Contributed by the community core Issues that should be addressed in Ray Core labels Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Contributed by the community core Issues that should be addressed in Ray Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants