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] Fix a memory leak due to lineage counting #31488

Merged
merged 6 commits into from
Jan 11, 2023

Conversation

fishbone
Copy link
Contributor

@fishbone fishbone commented Jan 6, 2023

Signed-off-by: Yi Cheng 74173148+iycheng@users.noreply.github.com

Why are these changes needed?

Assume two objects A and B and B depends on A. If A got delete first, it's won't be released because we need to preserve it for B.

The bug here is that even B is released, A won't be released and thus memory leak.

This PR fixed this issue by force delete the object when the ref goes to 0.

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 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: Yi Cheng <74173148+iycheng@users.noreply.github.com>
@@ -483,6 +483,7 @@ int64_t ReferenceCounter::ReleaseLineageReferences(ReferenceTable::iterator ref)
RAY_CHECK(arg_it->second.on_ref_removed == nullptr);
lineage_bytes_evicted += ReleaseLineageReferences(arg_it);
EraseReference(arg_it);
ReleasePlasmaObject(arg_it);
Copy link
Contributor

Choose a reason for hiding this comment

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

The fix looks good to me! I think we just need to move this to go before the above line, though, because the previous line deletes arg_it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I think you could also just call DeleteReferenceInternal instead of EraseReference and ReleasePlasmaObject.

Signed-off-by: Yi Cheng <74173148+iycheng@users.noreply.github.com>
Signed-off-by: Yi Cheng <74173148+iycheng@users.noreply.github.com>
Signed-off-by: Yi Cheng <74173148+iycheng@users.noreply.github.com>
Signed-off-by: Yi Cheng <74173148+iycheng@users.noreply.github.com>
@fishbone fishbone changed the title fix [core] Fix a memory leak due to lineage countint Jan 7, 2023
@fishbone fishbone changed the title [core] Fix a memory leak due to lineage countint [core] Fix a memory leak due to lineage counting Jan 7, 2023
@fishbone fishbone marked this pull request as ready for review January 7, 2023 00:34
RAY_CHECK(arg_it->second.on_ref_removed == nullptr);
lineage_bytes_evicted += ReleaseLineageReferences(arg_it);
EraseReference(arg_it);
DeleteReferenceInternal(arg_it, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rewrite the docstring for these 2 APIs? (EraseReference, DeleteReferenceInternal).

From reading the docstring, it is not clear why EraseReference doesn't work but DeleteReferenceInternal does from this code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realize that DeleteReferenceInternal also doesn't work. It need to be

ReleasePlasmaObject
EraseReference

I'm not very familiar with this part so I'm going to leave it here.

Signed-off-by: Yi Cheng <74173148+iycheng@users.noreply.github.com>
@fishbone fishbone linked an issue Jan 11, 2023 that may be closed by this pull request
@fishbone fishbone merged commit 037806a into ray-project:master Jan 11, 2023
AmeerHajAli pushed a commit that referenced this pull request Jan 12, 2023
Assume two objects A and B and B depends on A. If A got delete first, it's won't be released because we need to preserve it for B.

The bug here is that even B is released, A won't be released and thus memory leak.

This PR fixed this issue by force delete the object when the ref goes to 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Object store memory leak in simple while loop
3 participants