Skip to content
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

[Core] Decrement lineage ref count of an actor when the actor task return object reference is deleted #46230

Merged
merged 4 commits into from
Jun 25, 2024

Conversation

jjyao
Copy link
Collaborator

@jjyao jjyao commented Jun 24, 2024

Why are these changes needed?

std::vector<rpc::ObjectReference> TaskManager::AddPendingTask(..) {
   if (spec.IsActorTask()) {
    const auto actor_creation_return_id = spec.ActorCreationDummyObjectId();
    task_deps.push_back(actor_creation_return_id);
   }
}

When an actor method is called, the actor lineage ref count increments as it's seen as a dependency of the actor task.

However, when we know that the actor task won't be retried (i.e. the return object is out of scope), we forget to decrement the actor lineage ref count.

This PR fixes this so that we have a matching pair of increment and decrement.

Also removed some dead code.

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

…ject reference is deleted

Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
@jjyao jjyao changed the title [Core] Decrement lineage ref count of an actor when the actor task return ob… [Core] Decrement lineage ref count of an actor when the actor task return object reference is deleted Jun 24, 2024
@jjyao jjyao added the go add ONLY when ready to merge, run all tests label Jun 24, 2024
jjyao added 2 commits June 24, 2024 14:25
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
@jjyao jjyao marked this pull request as ready for review June 25, 2024 07:00
@jjyao jjyao requested review from a team, ericl, pcmoritz and raulchen as code owners June 25, 2024 07:00
Comment on lines +1244 to +1249
if (it->second.spec.IsActorTask()) {
// We need to decrement the actor lineage ref count here
// since it's incremented during TaskManager::AddPendingTask.
const auto actor_creation_return_id = it->second.spec.ActorCreationDummyObjectId();
released_objects->push_back(actor_creation_return_id);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actual fix

Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
@@ -82,33 +82,6 @@ inline std::shared_ptr<ray::rpc::ErrorTableData> CreateErrorTableData(
return error_info_ptr;
}

/// Helper function to produce actor table data.
inline std::shared_ptr<ray::rpc::ActorTableData> CreateActorTableData(
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this just unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, dead code

@jjyao jjyao merged commit 50926ac into ray-project:master Jun 25, 2024
6 checks passed
@jjyao jjyao deleted the jjyao/lineage branch June 25, 2024 18:51
@farmer00317558
Copy link

@jjyao Hello, I would like to ask, what phenomenon will this issue cause? Will it only affect the scenario where the Actor fails and retries? Or could it potentially lead to memory leaks during the execution of the Actor tasks?

I want to determine whether an upgrade to the latest version is necessary.

Thanks.

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