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][Streaming Generator] Fix memory leak from the end of object stream object #38152

Merged
merged 7 commits into from
Aug 8, 2023

Conversation

rkooo567
Copy link
Contributor

@rkooo567 rkooo567 commented Aug 5, 2023

Why are these changes needed?

// TODO(sang): This seems bad... We should delete the memory store

Currently, the objects are deleted from the memory store manually when the reference is removed (via __dealloc__ from ObjectRef class here;

worker.core_worker.remove_object_ref_reference(self)
).

This causes the leak from streaming generator because it doesn't actually create a Cython object ref class for the end of stream.

This PR fixes the issue by manually deleting the objects from memory store when the ref of streaming generator objects goes to 0.

In the long term, we should fix this by modifying reference_count.cc to actually delete the object from the memory store. I will follow up with this, but I chose the current solution as a short term because we should merge this by 2.6.3 (which we try to branch cut by Sun)

Related issue number

Closes #38089

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

edoakes and others added 4 commits August 5, 2023 18:54
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

Feels like there are cpp unit tests missing here to verify that the ref counting works as expected

@edoakes
Copy link
Contributor

edoakes commented Aug 6, 2023

@rkooo567 did you re-run the Serve repro to verify it's fixed? I'll kick off a long run on workspaces using these wheels too just to be sure.

@edoakes
Copy link
Contributor

edoakes commented Aug 6, 2023

Looks good

Screen Shot 2023-08-06 at 2 15 38 PM

@rkooo567
Copy link
Contributor Author

rkooo567 commented Aug 7, 2023

Feels like there are cpp unit tests missing here to verify that the ref counting works as expected

Good catch... Adding it now.

Btw, is it possible to add that long-running test as a regular long running test or some sort of release tests?

@rkooo567
Copy link
Contributor Author

rkooo567 commented Aug 7, 2023

Unit tests are added

@rickyyx rickyyx merged commit 373f5f1 into ray-project:master Aug 8, 2023
15 of 131 checks passed
rkooo567 added a commit to rkooo567/ray that referenced this pull request Aug 8, 2023
…ream object (ray-project#38152)

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
rickyyx pushed a commit that referenced this pull request Aug 8, 2023
… of object stream object #38152 (#38206)


---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
NripeshN pushed a commit to NripeshN/ray that referenced this pull request Aug 15, 2023
…ream object (ray-project#38152)

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: NripeshN <nn2012@hw.ac.uk>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
…ream object (ray-project#38152)

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: harborn <gangsheng.wu@intel.com>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
…ream object (ray-project#38152)


---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
…ream object (ray-project#38152)

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
vymao pushed a commit to vymao/ray that referenced this pull request Oct 11, 2023
…ream object (ray-project#38152)

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Victor <vctr.y.m@example.com>
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.

[Ray Serve] Memory leak in 2.6
5 participants