-
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-18016][SQL][FOLLOW-UP] Code Generation: Constant Pool Limit - reduce entries for mutable state #20036
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,7 +283,7 @@ case class InputAdapter(child: SparkPlan) extends UnaryExecNode with CodegenSupp | |
|
||
override def doProduce(ctx: CodegenContext): String = { | ||
// Right now, InputAdapter is only used when there is one input RDD. | ||
// inline mutable state since an inputAdaptor in a task | ||
// inline mutable state since an InputAdapter is used once in a task for WholeStageCodegen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
val input = ctx.addMutableState("scala.collection.Iterator", "input", v => s"$v = inputs[0];", | ||
forceInline = true) | ||
val row = ctx.freshName("row") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,20 +587,24 @@ case class HashAggregateExec( | |
fastHashMapClassName, groupingKeySchema, bufferSchema).generate() | ||
ctx.addInnerClass(generatedMap) | ||
|
||
// inline mutable state since not many aggregation operations in a task | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
fastHashMapTerm = ctx.addMutableState(fastHashMapClassName, "vectorizedHastHashMap", | ||
v => s"$v = new $fastHashMapClassName();") | ||
ctx.addMutableState(s"java.util.Iterator<InternalRow>", "vectorizedFastHashMapIter") | ||
v => s"$v = new $fastHashMapClassName();", forceInline = true) | ||
ctx.addMutableState(s"java.util.Iterator<InternalRow>", "vectorizedFastHashMapIter", | ||
forceInline = true) | ||
} else { | ||
val generatedMap = new RowBasedHashMapGenerator(ctx, aggregateExpressions, | ||
fastHashMapClassName, groupingKeySchema, bufferSchema).generate() | ||
ctx.addInnerClass(generatedMap) | ||
|
||
// inline mutable state since not many aggregation operations in a task | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
fastHashMapTerm = ctx.addMutableState(fastHashMapClassName, "fastHashMap", | ||
v => s"$v = new $fastHashMapClassName(" + | ||
s"$thisPlan.getTaskMemoryManager(), $thisPlan.getEmptyAggregationBuffer());") | ||
s"$thisPlan.getTaskMemoryManager(), $thisPlan.getEmptyAggregationBuffer());", | ||
forceInline = true) | ||
ctx.addMutableState( | ||
"org.apache.spark.unsafe.KVIterator<UnsafeRow, UnsafeRow>", | ||
"fastHashMapIter") | ||
"fastHashMapIter", forceInline = true) | ||
} | ||
} | ||
|
||
|
@@ -611,7 +615,7 @@ case class HashAggregateExec( | |
// create hashMap | ||
val hashMapClassName = classOf[UnsafeFixedWidthAggregationMap].getName | ||
hashMapTerm = ctx.addMutableState(hashMapClassName, "hashMap", | ||
v => s"$v = $thisPlan.createHashMap();") | ||
v => s"$v = $thisPlan.createHashMap();", forceInline = true) | ||
sorterTerm = ctx.addMutableState(classOf[UnsafeKVExternalSorter].getName, "sorter", | ||
forceInline = true) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,8 +440,9 @@ case class SortMergeJoinExec( | |
val spillThreshold = getSpillThreshold | ||
val inMemoryThreshold = getInMemoryThreshold | ||
|
||
// inline mutable state since not many join operations in a task | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
val matches = ctx.addMutableState(clsName, "matches", | ||
v => s"$v = new $clsName($inMemoryThreshold, $spillThreshold);") | ||
v => s"$v = new $clsName($inMemoryThreshold, $spillThreshold);", forceInline = true) | ||
// Copy the left keys as class members so they could be used in next function call. | ||
val matchedKeyVars = copyKeys(ctx, leftKeyVars) | ||
|
||
|
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.
ah, good catch!