Skip to content

[core] Avoid unnecessary deserialization/serialization of CallerWorkerId#53939

Merged
jjyao merged 2 commits intoray-project:masterfrom
Qiaolin-Yu:fix_workerid
Jun 19, 2025
Merged

[core] Avoid unnecessary deserialization/serialization of CallerWorkerId#53939
jjyao merged 2 commits intoray-project:masterfrom
Qiaolin-Yu:fix_workerid

Conversation

@Qiaolin-Yu
Copy link
Copy Markdown
Member

@Qiaolin-Yu Qiaolin-Yu commented Jun 19, 2025

Why are these changes needed?

task_spec.CallerWorkerId().Binary() has unnecessary deserialization/serialization.

To be more specific, CallerWorkerId() converts the worker ID from a binary string to the WorkerID, and .Binary() then converts it back to a binary string, which is unnecessary.

To avoid this, CallerWorkerIdBinary is added, which could return the binary string directly.

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 :(

Copilot AI review requested due to automatic review settings June 19, 2025 00:21
Copy link
Copy Markdown
Contributor

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

This PR introduces the CallerWorkerIdBinary() API to avoid unnecessary deserialization/serialization when obtaining the caller's worker ID.

  • Replaces calls to CallerWorkerId().Binary() with CallerWorkerIdBinary() in task cancellation code.
  • Adds a declaration and implementation for CallerWorkerIdBinary() in TaskSpecification to directly return the binary worker ID.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/ray/core_worker/transport/normal_task_submitter.cc Updated to use CallerWorkerIdBinary() for cancelling tasks.
src/ray/core_worker/transport/actor_task_submitter.cc Updated to use CallerWorkerIdBinary() for cancelling tasks.
src/ray/common/task/task_spec.h Declares the new CallerWorkerIdBinary() method with inline docs.
src/ray/common/task/task_spec.cc Implements CallerWorkerIdBinary() to return the raw worker ID.
Comments suppressed due to low confidence (1)

src/ray/common/task/task_spec.h:491

  • Ensure that unit tests are updated to verify that CallerWorkerIdBinary() correctly returns the expected binary worker ID and that behavior remains consistent with the previous implementation.
  std::string CallerWorkerIdBinary() const;

@Qiaolin-Yu Qiaolin-Yu requested a review from kevin85421 June 19, 2025 00:22
@kevin85421 kevin85421 added the go add ONLY when ready to merge, run all tests label Jun 19, 2025
@kevin85421
Copy link
Copy Markdown
Member

I have added go to this PR to trigger the full CI run. Please ping Jiajun or Edward to merge PR when all tests pass.

@Qiaolin-Yu
Copy link
Copy Markdown
Member Author

cc @jjyao

Copy link
Copy Markdown
Contributor

@israbbani israbbani left a comment

Choose a reason for hiding this comment

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

🚢

@jjyao jjyao enabled auto-merge (squash) June 19, 2025 18:14
@jjyao jjyao merged commit 023d497 into ray-project:master Jun 19, 2025
6 checks passed
minerharry pushed a commit to minerharry/ray that referenced this pull request Jun 27, 2025
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
…rId (#53939)

Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
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.

5 participants