-
Notifications
You must be signed in to change notification settings - Fork 986
Drill 4236: ExternalSort should use the new allocator functionality to better manage it's memory usage #317
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
af94bc6
DRILL-4236: ExternalSort should use the new allocator functionality t…
adeneche 1cfdead
ExternalSort uses allocator's stats to decide when to spill
adeneche 4f46fb6
Improved error message when OOM is external sort
adeneche 7fe4ee5
minor code cleanup
adeneche 527db3b
fixed issue in UserException.memoryError()
adeneche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Out of curiosity, what is this change? It seems strange.
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'm not sure actually. We use
addFirstin 2 places only andaddin 3 other places. Maybe I should just change all of them to useaddinstead.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.
The ordering in the queue only matters for determining which BatchGroups will be merged the next time mergeAndSpill is called. Since mergeAndSpill takes batches off the the end of the queue, we want to put the outcome at the front of the queue, since the outcome BatchGroup has a much larger spill size than the ones at the end of the queue, and is thus more expensive to merge.
So I think you should revert this change, and leave it the way it is. It might be a good idea to take more extensive look at the spilling/merging strategy, but that can be a different task.
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.
will revert the change.
I'm confused though, why do we sometimes (in 3 different places) add the outcome of
mergeAndSpillat the end of the queue ?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.
It depends on which queue we are merging from. When batches first come in to the ExternalSort, they are added to the batchGroup queue. Usually when spilling, we spill some number of batches from the batchGroup queue, and then put the result at the end of the spilledBatchGroup queue. In the cases where we need to re-merge the batchGroups, we take from the end of the spilledBatchGroup queue, and add them to the front of the queue.
If you are seeing a place where we mergeAndSpill the spilledBatchGroup queue and add to the end of the queue, that is a mistake and should be fixed.
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.
thanks Steven, I'm less confused now! The change is valid, because we are merging from the batchGroups queue.
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.
Yeah, since you also changed it so that we are spilling the batchGroup queue, this change does make sense.