-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-31864][SQL] Adjust AQE skew join trigger condition #28669
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 #123250 has finished for PR 28669 at commit
|
|
This makes sense to me. e.g. for partitions [1, 1, 1, ..., 1, 10], which are coalesced to @JkSelf what do you think? |
| if supportedJoinTypes.contains(joinType) => | ||
| assert(left.partitionsWithSizes.length == right.partitionsWithSizes.length) | ||
| val numPartitions = left.partitionsWithSizes.length | ||
| // We use the median size of the original shuffle partitions to detect skewed partitions. |
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 may also need to adjust the comment here.
|
Good improvement. Except one small comment. LGTM. |
|
Test build #123293 has finished for PR 28669 at commit
|
|
thanks, merging to master/3.0! |
This PR makes a minor change in deciding whether a partition is skewed by comparing the partition size to the median size of coalesced partitions instead of median size of raw partitions before coalescing. This change is line with target size criteria of splitting skew join partitions and can also cope with situations of extra empty partitions caused by over-partitioning. This PR has also improved skew join tests in AQE tests. No. Updated UTs. Closes apache#28669 from maryannxue/spark-31864. Authored-by: Maryann Xue <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit b9737c3) Signed-off-by: Wenchen Fan <[email protected]>
This PR makes a minor change in deciding whether a partition is skewed by comparing the partition size to the median size of coalesced partitions instead of median size of raw partitions before coalescing. This change is line with target size criteria of splitting skew join partitions and can also cope with situations of extra empty partitions caused by over-partitioning. This PR has also improved skew join tests in AQE tests. No. Updated UTs. Closes #28669 from maryannxue/spark-31864. Authored-by: Maryann Xue <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit b9737c3) Signed-off-by: Wenchen Fan <[email protected]>
|
@cloud-fan @maryannxue @JkSelf I'm seeing a case where partitions [0,0,0,...,13GB] were coalesced to [13GB] and took 17 min for a SortMergeJoin. With coalescing disabled, partitions would be split into [0,0,0,..., 256MB, 256MB,...,256MB] by OptimizeSkewedJoin and only took 38s. WDYT ? |
|
I think a single partition should be a special case. The median size doesn't make sense anymore and we should use the target partition size. Can you open a PR for it? |
|
I assume there's one only key in that 13G partition. You can always run into this when the number of distinct keys is smaller than the partition number. It is not a good idea to use median whether it's pre-coalescing size or post-coalescing size. Suppose, you have 100 keys, and the partition number is set to 200, even with pre-coalescing size, you won't get the skew handling you want, but with partition number being 201 you can. The skew behavior now depends on the partition number. However, it's probably the best we can do for now given we don't have a more advanced strategy here. So think we can:
|
|
@cloud-fan Do you want to target both cases or just the second ? @maryannxue I prefer option 1 since we can have a more general configuration that works good enough. |
|
I think the current status for 3.0 is good enough, as it's conservative to trigger the skew join optimization. @manuzhang can you send a PR to master branch to do the revert? We can still keep the test change though. |
|
@cloud-fan #28770 has been created. Please help review. |
|
@manuzhang |
|
@maryannxue |
|
@manuzhang If you adjust the configuration of |
|
@JkSelf That will work but the value doesn't make sense to me. In addition, I don't want to tune the configuration for every specific case but come up with a suite of default configurations that work out of box for most cases.
I don't see too much "meaning" here as we split the skewed partition towards the average size of coalesced non-skew partitions or advisory target size whichever is larger. We'll end up with evenly distributed partitions with or without this PR. However, we lose the chance to optimize skew partitions in some cases with this change. |
… condition ### What changes were proposed in this pull request? This reverts commit b9737c3 while keeping following changes * set default value of `spark.sql.adaptive.skewJoin.skewedPartitionFactor` to 5 * improve tests * remove unused imports ### Why are the changes needed? As discussed in #28669 (comment), revert SPARK-31864 for optimizing skew join to work for extremely clustered keys. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing tests. Closes #28770 from manuzhang/spark-31942. Authored-by: manuzhang <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
This PR makes a minor change in deciding whether a partition is skewed by comparing the partition size to the median size of coalesced partitions instead of median size of raw partitions before coalescing.
Why are the changes needed?
This change is line with target size criteria of splitting skew join partitions and can also cope with situations of extra empty partitions caused by over-partitioning. This PR has also improved skew join tests in AQE tests.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Updated UTs.