-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: track the memory usage of aggregate more accurate #34732
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. |
4a143bc
to
6224267
Compare
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/1f24e6fc3cc66963e3e78c169d22372cac353e43 |
// Golang Map needs to acquire double the memory when expanding, and the old buckets will be released after the data is migrated. | ||
// Considering the worst case, the data in the old bucket cannot be migrated in time, and the old bucket cannot | ||
// be GCed, we expand the bucket size to 1.5 times to estimate the memory usage of Golang Map. | ||
DefBucketMemoryUsageForMapStrToSlice = (8*(1+16+24) + 16) / 2 * 3 |
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.
ToPtr?
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.
No, because type aggPartialResultMapper map[string][]aggfuncs.PartialResult
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 59d4e60
|
TiDB MergeCI notify
|
What problem does this PR solve?
Issue Number: ref #33877
close #35635
Problem Summary:
At present, tidb's memory estimation for Golang Map only track the new buckets after expansion, and the old buckets will not be GCed immediately. Considering the worst case, the memory error will be 1.5 times. And GolangMap will definitely reach its peak value after the expansion, so we will expand the current memory statistics to 1.5 times, and reserve this part of the space for GolangMap
For StringSet, we shouldn't track the len(string), because map only save the pointer. We should track it when allocated.
The magic number in getGroupKeyMemUsage is wrong, and the unsafe.sizeof(slice) is 24.
We should track the memory usage of the pointer point to the PartialResult.
What is changed and how it works?
Check List
Tests
In the workload tpch-50g, try to run the aggregate function in q18: We can see that tidb tracks 39.0 GB.
See the heap profile: about 40495 MB(39.5 GB) memory inuse.
See the graph
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.