-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28361][SQL][TEST] Test equality of generated code with id in class name #25131
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
|
cc @cloud-fan |
|
Test build #107581 has finished for PR 25131 at commit
|
|
retest this please |
|
Test build #107584 has finished for PR 25131 at commit
|
| val after2 = bytecodeSizeHisto.getCount // same query shape as above, deliberately | ||
| // bytecodeSizeHisto's count is always monotonically increasing if new compilation to | ||
| // bytecode had occurred. If the count stayed the same that means we've got a cache hit. | ||
| assert(after1 == after2, "Should hit codegen cache. No new compilation to bytecode expected") |
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.
Why this can be flaky? If the generated code is the same then we should hit the cache. also cc @rednaxelafx
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.
sbt.ForkMain$ForkError: org.scalatest.exceptions.TestFailedException: 288738 did not equal 288749 Should hit codegen cache. No new compilation to bytecode expected
at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:528)
at org.scalatest.FunSuite.newAssertionFailedException(FunSuite.scala:1560)
at org.scalatest.Assertions$AssertionsHelper.macroAssert(Assertions.scala:501)
at org.apache.spark.sql.execution.WholeStageCodegenSuite$$anonfun$8$$anonfun$apply$mcV$sp$4.apply$mcV$sp(WholeStageCodegenSuite.scala:354)
at org.apache.spark.sql.catalyst.plans.PlanTestBase$class.withSQLConf(PlanTest.scala:176)
at org.apache.spark.sql.execution.WholeStageCodegenSuite.org$apache$spark$sql$test$SQLTestUtilsBase$$super$withSQLConf(WholeStageCodegenSuite.scala:35)
at org.apache.spark.sql.test.SQLTestUtilsBase$class.withSQLConf(SQLTestUtils.scala:175)
at org.apache.spark.sql.execution.WholeStageCodegenSuite.withSQLConf(WholeStageCodegenSuite.scala:35)
at org.apache.spark.sql.execution.WholeStageCodegenSuite$$anonfun$8.apply$mcV$sp(WholeStageCodegenSuite.scala:344)
at org.apache.spark.sql.execution.WholeStageCodegenSuite$$anonfun$8.apply(WholeStageCodegenSuite.scala:341)
at org.apache.spark.sql.execution.WholeStageCodegenSuite$$anonfun$8.apply(WholeStageCodegenSuite.scala:341)
at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at org.scalatest.FunSuiteLike$$anon$1.apply(FunSuiteLike.scala:186)
at org.apache.spark.SparkFunSuite.withFixture(SparkFunSuite.scala:74)
at org.scalatest.FunSuiteLike$class.invokeWithFixture$1(FunSuiteLike.scala:183)
at org.scalatest.FunSuiteLike$$anonfun$runTest$1.apply(FunSuiteLike.scala:196)
at org.scalatest.FunSuiteLike$$anonfun$runTest$1.apply(FunSuiteLike.scala:196)
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:289)
at org.scalatest.FunSuiteLike$class.runTest(FunSuiteLike.scala:196)
at org.apache.spark.sql.execution.WholeStageCodegenSuite.org$scalatest$BeforeAndAfterEach$$super$runTest(WholeStageCodegenSuite.scala:35)
at org.scalatest.BeforeAndAfterEach$class.runTest(BeforeAndAfterEach.scala:221)
at org.apache.spark.sql.execution.WholeStageCodegenSuite.runTest(WholeStageCodegenSuite.scala:35)
at org.scalatest.FunSuiteLike$$anonfun$runTests$1.apply(FunSuiteLike.scala:229)
at org.scalatest.FunSuiteLike$$anonfun$runTests$1.apply(FunSuiteLike.scala:229)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:396)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:384)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:379)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:461)
at org.scalatest.FunSuiteLike$class.runTests(FunSuiteLike.scala:229)
at org.scalatest.FunSuite.runTests(FunSuite.scala:1560)
at org.scalatest.Suite$class.run(Suite.scala:1147)
at org.scalatest.FunSuite.org$scalatest$FunSuiteLike$$super$run(FunSuite.scala:1560)
at org.scalatest.FunSuiteLike$$anonfun$run$1.apply(FunSuiteLike.scala:233)
at org.scalatest.FunSuiteLike$$anonfun$run$1.apply(FunSuiteLike.scala:233)
at org.scalatest.SuperEngine.runImpl(Engine.scala:521)
at org.scalatest.FunSuiteLike$class.run(FunSuiteLike.scala:233)
at org.apache.spark.SparkFunSuite.org$scalatest$BeforeAndAfterAll$$super$run(SparkFunSuite.scala:35)
at org.scalatest.BeforeAndAfterAll$class.liftedTree1$1(BeforeAndAfterAll.scala:213)
at org.scalatest.BeforeAndAfterAll$class.run(BeforeAndAfterAll.scala:210)
at org.apache.spark.SparkFunSuite.run(SparkFunSuite.scala:35)
at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:314)
at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:480)
at sbt.ForkMain$Run$2.call(ForkMain.java:296)
at sbt.ForkMain$Run$2.call(ForkMain.java:286)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
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 histogram of the time it took to compile source code text (in milliseconds) is not stable?
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 original version of this test shouldn't be flaky if it's run alone; but yes if there are Spark tests in parallel in the same JVM, then the CodegenMetrics can be modified as a side effect of other tests, so it's better to fix it.
The above comment is from @rednaxelafx
rednaxelafx
left a comment
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.
LGTM, thanks!
My old test was trying to peek into the system from an end-to-end perspective, but yes I agree it can be flaky and this new one is better.
| assert(after1 == after2, "Should hit codegen cache. No new compilation to bytecode expected") | ||
|
|
||
| // a different query can result in codegen cache miss, that's by design | ||
| // the same query run twice should produce identical code |
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.
Could we please add a phrase at the end of this line, something like:
, which would imply a hit in the generated code cache.
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.
+1, LGTM. (There is one @rednaxelafx 's request )
|
Since SPARK-23032 is merged at 2.3.0, could you backport this to |
|
I'll handle @rednaxelafx 's additional comment during merging. |
…lass name A code gen test in WholeStageCodeGenSuite was flaky because it used the codegen metrics class to test if the generated code for equivalent plans was identical under a particular flag. This patch switches the test to compare the generated code directly. N/A Closes #25131 from gatorsmile/WholeStageCodegenSuite. Authored-by: gatorsmile <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 60b89cf) Signed-off-by: Dongjoon Hyun <[email protected]>
…lass name A code gen test in WholeStageCodeGenSuite was flaky because it used the codegen metrics class to test if the generated code for equivalent plans was identical under a particular flag. This patch switches the test to compare the generated code directly. N/A Closes #25131 from gatorsmile/WholeStageCodegenSuite. Authored-by: gatorsmile <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 60b89cf) Signed-off-by: Dongjoon Hyun <[email protected]>
…lass name A code gen test in WholeStageCodeGenSuite was flaky because it used the codegen metrics class to test if the generated code for equivalent plans was identical under a particular flag. This patch switches the test to compare the generated code directly. N/A Closes apache#25131 from gatorsmile/WholeStageCodegenSuite. Authored-by: gatorsmile <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…lass name A code gen test in WholeStageCodeGenSuite was flaky because it used the codegen metrics class to test if the generated code for equivalent plans was identical under a particular flag. This patch switches the test to compare the generated code directly. N/A Closes apache#25131 from gatorsmile/WholeStageCodegenSuite. Authored-by: gatorsmile <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 60b89cf) Signed-off-by: Dongjoon Hyun <[email protected]>
…lass name A code gen test in WholeStageCodeGenSuite was flaky because it used the codegen metrics class to test if the generated code for equivalent plans was identical under a particular flag. This patch switches the test to compare the generated code directly. N/A Closes apache#25131 from gatorsmile/WholeStageCodegenSuite. Authored-by: gatorsmile <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 60b89cf) Signed-off-by: Dongjoon Hyun <[email protected]>
What changes were proposed in this pull request?
A code gen test in WholeStageCodeGenSuite was flaky because it used the codegen metrics class to test if the generated code for equivalent plans was identical under a particular flag. This patch switches the test to compare the generated code directly.
How was this patch tested?
N/A