-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
tikv_alloc: Add per thread memory usage #16255
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
@@ -545,6 +545,7 @@ where | |||
let t = thread::Builder::new() | |||
.name(name) | |||
.spawn_wrapper(move || { | |||
tikv_alloc::thread_allocate_exclusive_arena().unwrap(); |
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.
Does it mean memory arena can not be shared between threads?
Will it aggravate memory fragment or even OOM?
Can it tell how much memory is held (but not allocated) by a thread?
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.
-
By default, the number of arena is four times of CPU cores. So currently, it's already nearly one arena per one thread. So I don't think it would aggravate memory fragment in TiKV case.
-
What you mean by "held" is holding the memory allocated by other thread? Can't as allocator doesn't have the knowledge that the memory ownership is moved to another thread. At least, when it's freed in other threads, the memory usage accounted in the original allocated thread would be decreased.
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.
Should we consider implementing a configuration switch to disable this feature, as a precautionary measure in case it triggers unforeseen issues?
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.
According to the document, " There is a small fixed per-arena overhead, and additionally, arenas manage memory completely independently of each other, which means a small fixed increase in overall memory fragmentation. These overheads are not generally an issue, given the number of arenas normally used. Note that using substantially more arenas than the default is not likely to improve performance, mainly due to reduced cache performance. However, it may make sense to reduce the number of arenas if an application does not make much use of the allocation functions."
To make sure the overhead is small, can you run some read write mixed workload to compare the memory usage with and without this feature? @Connor1996
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.
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
/test |
@Connor1996: The
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/merge |
@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 7a3df1d
|
@Connor1996 you need to address the DCO first |
/test |
@Connor1996: The
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test pull-unit-test |
1 similar comment
/test pull-unit-test |
@Connor1996 Seems on test case need to be fixed |
/merge |
@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: c4fdfa9
|
/cherry-pick release-8.1 |
ref tikv#15927 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@Connor1996: new pull request created to branch In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
ref #15927 Add per thread memory usage Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io> Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Connor <zbk602423539@gmail.com> Co-authored-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
What is changed and how it works?
Issue Number: Ref #15927
What's Changed:
Jemalloc has mapped memory stats per arena. We can bind each thread with a dedicated arena, then we have per thread memory usage.
The total memory ~== block cache size + total of per thread footprint
Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note