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 Used Memory Calculation #20127

Merged
merged 2 commits into from
Nov 9, 2021
Merged

Conversation

lixin-wei
Copy link
Contributor

@lixin-wei lixin-wei commented Nov 6, 2021

Why are these changes needed?

total=used+free+buffers+cache. And available is not related to them all. It’s an estimation of how much memory is available for use without swapping.

We shouldn't calculate used memory as total-avail.

Related issue number

Checks

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

# also be considered as unused memory
if hasattr(psutil_mem, "cached"):
used_gb -= psutil_mem.cached / (1024**3)
used_gb = psutil_mem.used / (1024**3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, note;

According to the doc; https://psutil.readthedocs.io/en/latest/

used: memory used, calculated differently depending on the platform and designed for informational purposes only. total - free does not necessarily match used.

available: the memory that can be given instantly to processes without the system going into swap. This is calculated by summing different memory values depending on the platform and it is supposed to be used to monitor actual memory usage in a cross platform fashion.

@rkooo567
Copy link
Contributor

rkooo567 commented Nov 9, 2021

Failing tests seem unrelated.

@rkooo567 rkooo567 merged commit 8e666ca into ray-project:master Nov 9, 2021
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.

None yet

3 participants