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

util: fix wrong calculation to get memory usage. (#21158) #21160

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #21158 to release-3.0


What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
On MacOs, the calculation ignore inactive memory. It will make memory-alarm trigger unexpected.

What is changed and how it works?

Proposal: xxx

What's Changed:
Use mem.Used directly.
On MacOs, it should consider inactive memory.

ret.Available = ret.Free + ret.Inactive
ret.Used = ret.Total - ret.Available

On Linux, I read the source code. ret.Used = ret.Total - ret.Free - ret.Buffers - ret.Cached. So the result is same with old.

How it Works:

Related changes

Need cherry-pick to 3.0,4.0

Check List

Tests

Side effects

Release note

  • No release note

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@wshwsh12 you're already a collaborator in bot's repo.

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 20, 2020
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 20, 2020
@XuHuaiyu XuHuaiyu merged commit 2dbe7b2 into pingcap:release-3.0 Nov 20, 2020
@XuHuaiyu XuHuaiyu deleted the release-3.0-eca1ce192b0a branch November 20, 2020 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/LGT2 Indicates that a PR has LGTM 2. type/3.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants