-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[opt](memtracker) Optimize PODArray memory tracking accuracy
#50549
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
Conversation
|
run buildall |
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
TPC-H: Total hot run time: 34128 ms |
TPC-DS: Total hot run time: 198589 ms |
ClickBench: Total hot run time: 29.21 s |
e48af9d to
1524e5b
Compare
|
run buildall |
1524e5b to
06383a4
Compare
|
run buildall |
e0fdf9c to
83987d6
Compare
|
run buildall |
83987d6 to
7c479b7
Compare
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
7c479b7 to
4256478
Compare
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
4256478 to
82236d4
Compare
|
run buildall |
TPC-H: Total hot run time: 33949 ms |
TPC-DS: Total hot run time: 186179 ms |
ClickBench: Total hot run time: 29.09 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
1 similar comment
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
mrhhsg
left a comment
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.
lgtm
…e#50549) ### What problem does this PR solve? Based on apache#11740 The memory size tracked in Allocator is virtual memory. If the allocated memory is not fully used, the tracked virtual memory may be larger than the actual physical memory. `PODArray` does not memset 0 when allocated memory, the memory blocks allocated by `PODArray` (such as VOlapScanNode::_free_blocks) are usually used for memory reuse and will not be fully used. After this PR, the unused memory in `PODArray` is recorded in reserve to indicate that this part of the memory is not actually used.
### What problem does this PR solve? #50549 may cause performance loss If capacity_bytes <= 256K, res_mem_growth = c_end_of_storage - c_res_mem. If capacity >= 512K: - If `c_end_of_storage - c_res_mem < TrackingGrowthMinSize`, then tracking to c_end_of_storage. - `c_end_new - c_res_mem` is the size of the physical memory growth, which is also the minimum tracking size of this time, `(((c_end_new - c_res_mem) >> 16) << 16)` is aligned down to 64K, assuming `capacity_bytes >= 512K`, so `(capacity_bytes >> 3)` is at least 64K, so `(((c_end_new - c_res_mem) >> 16) << 16) + (capacity_bytes() >> 3)` must be greater than `c_end_new - c_res_mem`. For example: - 256K < capacity <= 512K, it will only tracking twice, the second time `c_end_of_storage - c_res_mem < TrackingGrowthMinSize` is true, so it will tracking to c_end_of_storage. - capacity > 32M, `(((c_end_new - c_res_mem) >> 16) << 16)` align the increased physical memory size down to 64k, then add `(capacity_bytes() >> 3)` equals 2M, so `reset_resident_memory` is tracking an additional 2M, after that, physical memory growth within 2M does not need to reset_resident_memory again. so, when PODArray is expanded by power of 2, the memory is checked and tracked up to 8 times between each expansion, because each time additional tracking `(capacity_bytes() >> 3)`. after each reset_resident_memory, tracking_res_memory >= used_bytes;
…2553) ### What problem does this PR solve? apache#50549 may cause performance loss If capacity_bytes <= 256K, res_mem_growth = c_end_of_storage - c_res_mem. If capacity >= 512K: - If `c_end_of_storage - c_res_mem < TrackingGrowthMinSize`, then tracking to c_end_of_storage. - `c_end_new - c_res_mem` is the size of the physical memory growth, which is also the minimum tracking size of this time, `(((c_end_new - c_res_mem) >> 16) << 16)` is aligned down to 64K, assuming `capacity_bytes >= 512K`, so `(capacity_bytes >> 3)` is at least 64K, so `(((c_end_new - c_res_mem) >> 16) << 16) + (capacity_bytes() >> 3)` must be greater than `c_end_new - c_res_mem`. For example: - 256K < capacity <= 512K, it will only tracking twice, the second time `c_end_of_storage - c_res_mem < TrackingGrowthMinSize` is true, so it will tracking to c_end_of_storage. - capacity > 32M, `(((c_end_new - c_res_mem) >> 16) << 16)` align the increased physical memory size down to 64k, then add `(capacity_bytes() >> 3)` equals 2M, so `reset_resident_memory` is tracking an additional 2M, after that, physical memory growth within 2M does not need to reset_resident_memory again. so, when PODArray is expanded by power of 2, the memory is checked and tracked up to 8 times between each expansion, because each time additional tracking `(capacity_bytes() >> 3)`. after each reset_resident_memory, tracking_res_memory >= used_bytes;
What problem does this PR solve?
Based on #11740
The memory size tracked in Allocator is virtual memory. If the allocated memory is not fully used, the tracked virtual memory may be larger than the actual physical memory.
PODArraydoes not memset 0 when allocated memory, the memory blocks allocated byPODArray(such as VOlapScanNode::_free_blocks) are usually used for memory reuse and will not be fully used.After this PR, the unused memory in
PODArrayis recorded in reserve to indicate that this part of the memory is not actually used.Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)