-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improvement](spill) avoid spill if memory is enough #33075
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
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
TeamCity be ut coverage result: |
TPC-H: Total hot run time: 38742 ms |
TPC-DS: Total hot run time: 181873 ms |
ClickBench: Total hot run time: 30.6 s |
|
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
| local_state._mem_tracker->set_consumption( | ||
| local_state._shared_state->in_mem_shared_state->sorter->data_size()); | ||
| if (eos) { | ||
| if (_enable_spill) { |
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.
I think spill_sort_sink_operator is used when _enable_spill== true. So that I think this variable is always true in this case??
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.
We currently only support spill for full sort, but when creating the sort operatorX, it's hard to decide whether it's full sort.
It's in the SortSinkOperatorX::prepare phase to decide whether to use full sort, so we create
SpillSortSinkOperatorX when enable_sort_spill=true for all type of sort, but actually only enable spillable sort for full sort.
| auto& local_state = get_local_state(state); | ||
| Defer defer([&] { | ||
| if (*eos) { | ||
| LOG(INFO) << "hash probe " << id() << " eos"; |
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.
This is a debug message?
| RETURN_IF_ERROR(revoke_memory(state)); | ||
| local_state.profile()->add_info_string( | ||
| "Spilled", local_state._shared_state->is_spilled ? "true" : "false"); | ||
| LOG(INFO) << "sort node " << id() |
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.
This is a debug message?
|
|
||
| RETURN_IF_ERROR(local_state.initiate_merge_spill_partition_agg_data(state)); | ||
| if (local_state._shared_state->is_spilled) { | ||
| RETURN_IF_ERROR(local_state.initiate_merge_spill_partition_agg_data(state)); |
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.
This method will merge block again. Do we need clear the previous partition data??
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.
initiate_merge_spill_partition_agg_data will check whether the current partition still has data, if it is, it continue to output data from the current partition; if not, will merge the next partition.
|
|
||
| RETURN_IF_ERROR(local_state.initiate_merge_spill_partition_agg_data(state)); | ||
| if (local_state._shared_state->is_spilled) { | ||
| RETURN_IF_ERROR(local_state.initiate_merge_spill_partition_agg_data(state)); |
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.
why call init merge every time?? It is only called the first time or meet previous partition's EOS?
| RETURN_IF_ERROR(partition->finish_current_spilling(eos)); | ||
| local_state.profile()->add_info_string( | ||
| "Spilled", local_state._shared_state->is_spilled ? "true" : "false"); | ||
| LOG(INFO) << "agg node " << id() |
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.
This is debug log?
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.
If profile is not enabled, we can seach log to check if query is spilled.
| } else { | ||
| for (auto& partition : local_state._shared_state->spill_partitions) { | ||
| RETURN_IF_ERROR(partition->finish_current_spilling(eos)); | ||
| local_state.profile()->add_info_string( |
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.
Not meet EOS.
Shoud add this to profile when the spilled is set to true at first time.
Because we will provide realtime profile in the future, user will find his query is spilled to disk.
If we set it when eos, then user will not find ths spill task when the query not spilled finished.
877e5f6 to
6638112
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
TeamCity be ut coverage result: |
TPC-H: Total hot run time: 38791 ms |
TPC-DS: Total hot run time: 181785 ms |
ClickBench: Total hot run time: 30.56 s |
|
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
yiguolei
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
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
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
Proposed changes
Issue Number: close #xxx
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...