Skip to content

Conversation

@gatorsmile
Copy link
Member

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

@gatorsmile gatorsmile requested a review from cloud-fan July 12, 2019 06:35
@gatorsmile
Copy link
Member Author

cc @cloud-fan

@SparkQA
Copy link

SparkQA commented Jul 12, 2019

Test build #107581 has finished for PR 25131 at commit ba91966.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@wangyum
Copy link
Member

wangyum commented Jul 12, 2019

retest this please

@SparkQA
Copy link

SparkQA commented Jul 12, 2019

Test build #107584 has finished for PR 25131 at commit ba91966.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

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")
Copy link
Contributor

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

Copy link
Member Author

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)

Copy link
Member Author

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?

Copy link
Member Author

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

Copy link
Contributor

@rednaxelafx rednaxelafx left a 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
Copy link
Contributor

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.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a 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 )

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-28361] [SQL] [TEST] Test equality of generated code with id in class name [SPARK-28361][SQL][TEST] Test equality of generated code with id in class name Jul 12, 2019
@dongjoon-hyun
Copy link
Member

Since SPARK-23032 is merged at 2.3.0, could you backport this to 2.4/2.3?

@dongjoon-hyun
Copy link
Member

I'll handle @rednaxelafx 's additional comment during merging.

dongjoon-hyun pushed a commit that referenced this pull request Jul 12, 2019
…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]>
dongjoon-hyun pushed a commit that referenced this pull request Jul 12, 2019
…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]>
vinodkc pushed a commit to vinodkc/spark that referenced this pull request Jul 18, 2019
…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]>
rluta pushed a commit to rluta/spark that referenced this pull request Sep 17, 2019
…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]>
kai-chi pushed a commit to kai-chi/spark that referenced this pull request Sep 26, 2019
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants