-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-12688][SQL] Fix spill size metric in unsafe external sorter #10634
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
|
Test build #48913 has finished for PR 10634 at commit
|
|
Test build #48915 has finished for PR 10634 at commit
|
|
Test build #48923 has finished for PR 10634 at commit
|
|
Test build #48992 has finished for PR 10634 at commit
|
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.
According to my understanding of spill metrics, a spill needs to update both memoryBytesSpilled and diskBytesSpilled. The memory spill is the in-memory size of the data being spilled, while the disk spill records the size of that data after it has been serialized and written to disk. As a result, I think that there must be a corresponding incDiskBytesSpilled call somewhere. I'm thinking that this memory spill metric should be updated closer to the site of where we increment the disk bytes spilled rather than here, since I think doing it that way would make it easier to reason about whether we're double-counting.
If this does turn out to be the right place for this spill, it would be great to add a code comment explaining the rationale for why this call must be here.
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.
Ping @carsonwang, do you plan to update this PR to address my 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.
Sorry for the delay, @JoshRosen . I will update this soon.
|
retest this please |
|
Test build #49974 has finished for PR 10634 at commit
|
|
@JoshRosen , I now also update |
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.
For Sql aggregation, the spillSize here is 0 because the data are stored in a map instead of this sorter. So incMemoryBytesSpilled(spillSize) actually increase 0. We need update the MemoryBytesSpilled after freeing the memory in the map.
|
retest this please |
|
Test build #49976 has finished for PR 10634 at commit
|
|
Test build #49984 has finished for PR 10634 at commit
|
|
Test build #49983 has finished for PR 10634 at commit
|
|
@JoshRosen , do you have any further comments? |
|
/cc @cloud-fan @andrewor14 , did you guys see spill size > 0 when the UI was introduced? Can you take a look at this fix? |
|
is it possible to write a test for this bug? |
|
Test build #50857 has finished for PR 10634 at commit
|
|
Thanks for the pull request. I'm going through a list of pull requests to cut them down since the sheer number is breaking some of the tooling we have. Due to lack of activity on this pull request, I'm going to push a commit to close it. Feel free to reopen it or create a new one. We can also continue the discussion on the JIRA ticket. |
When doing a sql aggregation in tungsten mode, the spill size metric may not update though there are data spilled. Because the data are stored in the

BytesToBytesMapinstead ofUnsafeExternalSorter, the memory are freed when the map resets instead of when the sorter spills.