-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-13293] [SQL] generate Expand #11177
Conversation
As always, can you paste the generated code? :) |
Test build #51156 has finished for PR 11177 at commit
|
} | ||
} | ||
|
||
// In order to prevent code exploration, we can't call `consume()` many times, so we call |
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.
what do you mean by "code exploration"?
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.
btw any perf degradation from not unrolling the loop?
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 loop and copy two variables should only take about 1-2 nano second, should not have regressions.
But if we don't have loop here, then the generated code could be much easier to be larger than 8K, that could be regression (slower than without codegen).
The part of generated code for
|
@rxin Had posted the generated code, add more comments. |
override def doConsume(ctx: CodegenContext, input: Seq[ExprCode]): String = { | ||
// Some columns have the same expression in all the projections, so collect the unique | ||
// expressions. | ||
val columnUniqueExpressions: IndexedSeq[Set[Expression]] = output.indices.map { i => |
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 this one, can we explain what the indexes are, and what the expressions are?
Test build #51205 has finished for PR 11177 at commit
|
Test build #51219 has finished for PR 11177 at commit
|
@@ -17,11 +17,15 @@ | |||
|
|||
package org.apache.spark.sql.execution | |||
|
|||
import scala.collection.immutable.IndexedSeq |
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 no longer necessary. can you remove it in some other pr you have?
LGTM. Merging in master. |
Expand suffer from create the UnsafeRow from same input multiple times, with codegen, it only need to copy some of the columns.
After this, we can see 3X improvements (from 43 seconds to 13 seconds) on a TPCDS query (Q67) that have eight columns in Rollup.
Ideally, we could mask some of the columns based on bitmask, I'd leave that in the future, because currently Aggregation (50 ns) is much slower than that just copy the variables (1-2 ns).