This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
feat: optimize tcmalloc release memory #343
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acelyc111
reviewed
Nov 28, 2019
hycdong
requested review from
acelyc111,
levy5307,
neverchanje,
foreverneverer and
vagetablechicken
November 28, 2019 07:23
acelyc111
reviewed
Nov 28, 2019
acelyc111
previously approved these changes
Nov 29, 2019
neverchanje
reviewed
Nov 29, 2019
这个单测测试的kudu的函数 |
neverchanje
approved these changes
Nov 29, 2019
neverchanje
reviewed
Nov 29, 2019
if (!dsn::buf2int32(args[0], percentage) || percentage <= 0 || percentage >= 100) { | ||
result = std::string("ERR: invalid arguments"); | ||
} else { | ||
_mem_release_max_reserved_mem_percentage = percentage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 remote command 还是建议抽出来一个函数然后写单测
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 这几处代码都很类似,可以抽象出一个函数来, 几个remote command都复用。另起一个PR做吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,remote command整个可以抽出来,之后的pr再做吧
acelyc111
approved these changes
Nov 29, 2019
Smityz
added a commit
to Smityz/rdsn
that referenced
this pull request
Nov 29, 2019
feat: optimize tcmalloc release memory (XiaoMi#343)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this pr solved
Pull request #278 add a new feature that releasing memory periodically by tcmalloc
ReleaseFreeMemory
.ReleaseFreeMemory
will release all tcmalloc reserved and not-used memory back to operating system. Releasing memory will lockpage heap
, the structure used to allocate memory from operating system and release memory back to operating system, shared by all threads. As a result, releasing all free memory will lockpage heap
for a long time and block all threads, more seriously, it will affect cluster performance. More tcmalloc information can be find in tcmalloc website.So we optimize the releasing memory method, which is similar to kudu's way (kudu gc_memory).
We use tcmalloc statistics below:
We set a maximum percentage
p
, we assume that tcmalloc reserved but not-used memory should not be greaterwhole_used_memory * p
, if exceed this threshold, we will release the exceeding memory byReleaseToSystem
. To avoid lockingpage heap
for a long time, we only release 1MB at a time.Besides, we make such percentage
mem_release_max_reserved_mem_percentage
configurable dynamically. Cluster administrator can show and change this value byremote_command
.Config updates
Add two new config
remove config
mem_release_interval_ms