Skip to content

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

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

jjyao merged 2 commits into
ray-project:masterfrom
Qiaolin-Yu:fix_workerid

Conversation

@Qiaolin-Yu

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

Copy link
Copy Markdown
Member

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

Copilot AI review requested due to automatic review settings June 19, 2025 00:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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;

Comment thread src/ray/common/task/task_spec.cc Resolved
@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

Comment thread src/ray/common/task/task_spec.h Resolved
Comment thread src/ray/common/task/task_spec.h Resolved

@israbbani israbbani left a comment

Copy link
Copy Markdown
Contributor

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