[GitHub] [spark] kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints bytecode statistics in debugCodegen

2019-09-15 Thread GitBox
kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints 
bytecode statistics in debugCodegen
URL: https://github.com/apache/spark/pull/25766#discussion_r324498462
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/debug/package.scala
 ##
 @@ -81,11 +82,21 @@ package object debug {
   def writeCodegen(append: String => Unit, plan: SparkPlan): Unit = {
 val codegenSeq = codegenStringSeq(plan)
 append(s"Found ${codegenSeq.size} WholeStageCodegen subtrees.\n")
-for (((subtree, code), i) <- codegenSeq.zipWithIndex) {
-  append(s"== Subtree ${i + 1} / ${codegenSeq.size} ==\n")
+for (((subtree, code, codeStats), i) <- codegenSeq.zipWithIndex) {
+  val usedConstPoolRatio = if (codeStats.maxConstPoolSize > 0) {
+val rt = 100.0 * codeStats.maxConstPoolSize / 
CodeGenerator.MAX_JVM_CONSTANT_POOL_SIZE
+"(%.2f%% used)".format(rt)
+  } else {
+""
+  }
+  val codeStatsStr = s"maxClassCodeSize:${codeStats.maxClassCodeSize}; " +
 
 Review comment:
   @maropu Could you elaborate on your idea to add this?
   
   How about adding ratio of `maxMethodCodeSize` / 
`CodeGenerator.DEFAULT_JVM_HUGE_METHOD_LIMIT`, too?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints bytecode statistics in debugCodegen

2019-09-13 Thread GitBox
kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints 
bytecode statistics in debugCodegen
URL: https://github.com/apache/spark/pull/25766#discussion_r324070844
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/debug/package.scala
 ##
 @@ -81,11 +82,21 @@ package object debug {
   def writeCodegen(append: String => Unit, plan: SparkPlan): Unit = {
 val codegenSeq = codegenStringSeq(plan)
 append(s"Found ${codegenSeq.size} WholeStageCodegen subtrees.\n")
-for (((subtree, code), i) <- codegenSeq.zipWithIndex) {
-  append(s"== Subtree ${i + 1} / ${codegenSeq.size} ==\n")
+for (((subtree, code, codeStats), i) <- codegenSeq.zipWithIndex) {
+  val usedConstPoolRatio = if (codeStats.maxConstPoolSize > 0) {
+val rt = 100.0 * codeStats.maxConstPoolSize / 
CodeGenerator.MAX_JVM_CONSTANT_POOL_SIZE
+"(%.2f%% used)".format(rt)
+  } else {
+""
+  }
+  val codeStatsStr = s"maxClassCodeSize:${codeStats.maxClassCodeSize}; " +
 
 Review comment:
   I am neutral on this. I am bit worry about the wider width regarding ease of 
reading._


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints bytecode statistics in debugCodegen

2019-09-12 Thread GitBox
kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints 
bytecode statistics in debugCodegen
URL: https://github.com/apache/spark/pull/25766#discussion_r324052815
 
 

 ##
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/debug/package.scala
 ##
 @@ -81,11 +82,21 @@ package object debug {
   def writeCodegen(append: String => Unit, plan: SparkPlan): Unit = {
 val codegenSeq = codegenStringSeq(plan)
 append(s"Found ${codegenSeq.size} WholeStageCodegen subtrees.\n")
-for (((subtree, code), i) <- codegenSeq.zipWithIndex) {
-  append(s"== Subtree ${i + 1} / ${codegenSeq.size} ==\n")
+for (((subtree, code, codeStats), i) <- codegenSeq.zipWithIndex) {
+  val usedConstPoolRatio = if (codeStats.maxConstPoolSize > 0) {
+val rt = 100.0 * codeStats.maxConstPoolSize / 
CodeGenerator.MAX_JVM_CONSTANT_POOL_SIZE
+"(%.2f%% used)".format(rt)
+  } else {
+""
+  }
+  val codeStatsStr = s"maxClassCodeSize:${codeStats.maxClassCodeSize}; " +
 
 Review comment:
   How about `maxClassSize` instead of `maxClassCodeSize`? `maxClassCodeSize` 
may imply max bytecode size in a class.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints bytecode statistics in debugCodegen

2019-09-12 Thread GitBox
kiszk commented on a change in pull request #25766: [SPARK-29061][SQL] Prints 
bytecode statistics in debugCodegen
URL: https://github.com/apache/spark/pull/25766#discussion_r323676315
 
 

 ##
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 ##
 @@ -1353,19 +1370,17 @@ object CodeGenerator extends Logging {
 byteCodeSize
   }
 }
-Some(stats)
+(classCodeSize, methodCodeSizes.max, constPoolSize)
   } catch {
 case NonFatal(e) =>
   logWarning("Error calculating stats of compiled class.", e)
-  None
+  (classCodeSize, -1, -1)
   }
-}.flatten
-
-if (codeSizes.nonEmpty) {
-  codeSizes.max
-} else {
-  0
 }
+
+ByteCodeStats(codeStats.reduce[(Int, Int, Int)] { case (v1, v2) =>
+  (Math.max(v1._1, v2._1), Math.max(v1._2, v2._2), Math.max(v1._3, v2._3))
 
 Review comment:
   I like this direction.
   
   May we see these values regarding different classes? Is it better to show 
class name and method name, too?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org