Skip to content

[core][3/N] Avoid unnecessary deserialization/serialization of ParentTaskId#53695

Merged
edoakes merged 1 commit intoray-project:masterfrom
kevin85421:laptop-ray2-20250610
Jun 10, 2025
Merged

[core][3/N] Avoid unnecessary deserialization/serialization of ParentTaskId#53695
edoakes merged 1 commit intoray-project:masterfrom
kevin85421:laptop-ray2-20250610

Conversation

@kevin85421
Copy link
Copy Markdown
Member

@kevin85421 kevin85421 commented Jun 10, 2025

Why are these changes needed?

task_spec.ParentTaskId().Binary()
  • ParentTaskId() deserializes binary to TaskId.
  • Binary() serializes TaskId to binary.

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: Kai-Hsun Chen <kaihsun@anyscale.com>
@kevin85421 kevin85421 added the go add ONLY when ready to merge, run all tests label Jun 10, 2025
@kevin85421 kevin85421 marked this pull request as ready for review June 10, 2025 16:29
Copilot AI review requested due to automatic review settings June 10, 2025 16:29
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 a new ParentTaskIdBinary() method to avoid extra serialization/deserialization of the parent task ID and updates usage sites accordingly.

  • Added ParentTaskIdBinary() to return the raw binary ID without wrapping
  • Replaced ParentTaskId().Binary() calls in stats gathering with ParentTaskIdBinary()
  • Handled empty parent ID explicitly to return a nil ID binary

Reviewed Changes

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

File Description
src/ray/core_worker/task_manager.cc Swapped ParentTaskId().Binary() for ParentTaskIdBinary()
src/ray/common/task/task_spec.h Declared new ParentTaskIdBinary() API
src/ray/common/task/task_spec.cc Implemented ParentTaskIdBinary(), handling empty ID as nil
Comments suppressed due to low confidence (2)

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

  • [nitpick] Consider using a Doxygen-style comment (/** ... */) and clarifying that this returns the raw serialized ID, returning the nil representation when unset.
// Get the parent task id in binary format.

src/ray/common/task/task_spec.cc:180

  • There are no unit tests covering the new ParentTaskIdBinary() behavior; consider adding tests for both empty (nil) and non-empty parent IDs to prevent regressions.
if (message_->parent_task_id().empty()) {

@edoakes edoakes merged commit a6c5ecf into ray-project:master Jun 10, 2025
5 checks passed
elliot-barn pushed a commit that referenced this pull request Jun 18, 2025
…TaskId (#53695)

```cpp
task_spec.ParentTaskId().Binary()
```
* `ParentTaskId()` deserializes binary to `TaskId`.
* `Binary()` serializes `TaskId` to binary.

Signed-off-by: Kai-Hsun Chen <kaihsun@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
…TaskId (#53695)

```cpp
task_spec.ParentTaskId().Binary()
```
* `ParentTaskId()` deserializes binary to `TaskId`.
* `Binary()` serializes `TaskId` to binary.

Signed-off-by: Kai-Hsun Chen <kaihsun@anyscale.com>
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.

3 participants