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. DetailsReviewer can indicate their review by submitting an approval review. |
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
| let t = thread::Builder::new() | ||
| .name(name) | ||
| .spawn_wrapper(move || { | ||
| tikv_alloc::thread_allocate_exclusive_arena().unwrap(); |
There was a problem hiding this comment.
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.
-
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.
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.
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
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>
|
/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
DetailsInstructions 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. DetailsCommit 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 DetailsIn 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>
|
/cherry-pick release-7.5 |
ref tikv#15927 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
@hhwyt: new pull request created to branch DetailsIn 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. |
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
…age tikv#16255" into CSE. (tikv#2626) * [Cherry-pick after rebase] port "tikv_alloc: Add per thread memory usage tikv#16255" into CSE. Signed-off-by: lucasliang <nkcs_lykx@hotmail.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