aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src/main/scala/org/apache
diff options
context:
space:
mode:
authorDavies Liu <davies@databricks.com>2016-08-22 16:16:03 +0800
committerWenchen Fan <wenchen@databricks.com>2016-08-22 16:16:03 +0800
commit8d35a6f68d6d733212674491cbf31bed73fada0f (patch)
tree4574a1aeef90dab75b1300abb599632cde3973e7 /sql/catalyst/src/main/scala/org/apache
parent4b6c2cbcb109c7cef6087bae32d87cc3ddb69cf9 (diff)
downloadspark-8d35a6f68d6d733212674491cbf31bed73fada0f.tar.gz
spark-8d35a6f68d6d733212674491cbf31bed73fada0f.tar.bz2
spark-8d35a6f68d6d733212674491cbf31bed73fada0f.zip
[SPARK-17115][SQL] decrease the threshold when split expressions
## What changes were proposed in this pull request? In 2.0, we change the threshold of splitting expressions from 16K to 64K, which cause very bad performance on wide table, because the generated method can't be JIT compiled by default (above the limit of 8K bytecode). This PR will decrease it to 1K, based on the benchmark results for a wide table with 400 columns of LongType. It also fix a bug around splitting expression in whole-stage codegen (it should not split them). ## How was this patch tested? Added benchmark suite. Author: Davies Liu <davies@databricks.com> Closes #14692 from davies/split_exprs.
Diffstat (limited to 'sql/catalyst/src/main/scala/org/apache')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
index 16fb1f6837..4bd9ee03f9 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
@@ -584,15 +584,18 @@ class CodegenContext {
* @param expressions the codes to evaluate expressions.
*/
def splitExpressions(row: String, expressions: Seq[String]): String = {
- if (row == null) {
+ if (row == null || currentVars != null) {
// Cannot split these expressions because they are not created from a row object.
return expressions.mkString("\n")
}
val blocks = new ArrayBuffer[String]()
val blockBuilder = new StringBuilder()
for (code <- expressions) {
- // We can't know how many byte code will be generated, so use the number of bytes as limit
- if (blockBuilder.length > 64 * 1000) {
+ // We can't know how many bytecode will be generated, so use the length of source code
+ // as metric. A method should not go beyond 8K, otherwise it will not be JITted, should
+ // also not be too small, or it will have many function calls (for wide table), see the
+ // results in BenchmarkWideTable.
+ if (blockBuilder.length > 1024) {
blocks.append(blockBuilder.toString())
blockBuilder.clear()
}