summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-10-08 11:30:23 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-10-10 15:23:39 +1000
commitf6d72991bbba9a9610a9873424b3506f2b26be3f (patch)
tree6b3f2f505e97c013379ffeac70851f97055c429e /test
parentd6cb47cbc4bc5468b42eda87a90c865728b84c6a (diff)
downloadscala-f6d72991bbba9a9610a9873424b3506f2b26be3f.tar.gz
scala-f6d72991bbba9a9610a9873424b3506f2b26be3f.tar.bz2
scala-f6d72991bbba9a9610a9873424b3506f2b26be3f.zip
SI-8893 Restore linear perf in TailCalls with nested matches
Compilation perfomance of the enclosed test regressed when the new pattern matcher was introduced, specifically when the tail call elimination phase was made aware of its tree shapes in cd3d34203. The code added in that commit detects an application to a tail label in order to treat recursive calls in the argument as in tail position. If the transform of that argument makes no change, it falls back to `rewriteApply`, which transforms the argument again (although this time on a non-tail-position context.) This commit avoids the second transform by introducing a flag to `rewriteApply` to mark the arguments are pre-transformed. I don't yet see how that fixes the exponential performance, as on the surface it seems like a constant factor improvement. But the numbers don't lie, and we can now compile the test case in seconds, rather than before when it was running for > 10 minutes. This test case was based on a code pattern generated by the Avro serializer macro in: https://github.com/paytronix/utils-open/tree/release/2014/ernststavrosgrouper The exponential performance in that context is visualed here: https://twitter.com/dridus/status/519544110173007872 Thanks for @rmacleod2 for minimizing the problem.
Diffstat (limited to 'test')
-rw-r--r--test/files/pos/t8893.scala129
1 files changed, 129 insertions, 0 deletions
diff --git a/test/files/pos/t8893.scala b/test/files/pos/t8893.scala
new file mode 100644
index 0000000000..b87c8bdd3c
--- /dev/null
+++ b/test/files/pos/t8893.scala
@@ -0,0 +1,129 @@
+// Took > 10 minutes to run the tail call phase.
+object Test {
+ def a(): Option[String] = Some("a")
+
+ def main(args: Array[String]) {
+ a() match {
+ case Some(b1) =>
+ a() match {
+ case Some(b2) =>
+ a() match {
+ case Some(b3) =>
+ a() match {
+ case Some(b4) =>
+ a() match {
+ case Some(b5) =>
+ a() match {
+ case Some(b6) =>
+ a() match {
+ case Some(b7) =>
+ a() match {
+ case Some(b8) =>
+ a() match {
+ case Some(b9) =>
+ a() match {
+ case Some(b10) =>
+ a() match {
+ case Some(b11) =>
+ a() match {
+ case Some(b12) =>
+ a() match {
+ case Some(b13) =>
+ a() match {
+ case Some(b14) =>
+ a() match {
+ case Some(b15) =>
+ a() match {
+ case Some(b16) =>
+ a() match {
+ case Some(b17) =>
+ a() match {
+ case Some(b18) =>
+ a() match {
+ case Some(b19) =>
+ a() match {
+ case Some(b20) =>
+ a() match {
+ case Some(b21) =>
+ a() match {
+ case Some(b22) =>
+ a() match {
+ case Some(b23) =>
+ a() match {
+ case Some(b24) =>
+ a() match {
+ case Some(b25) =>
+ a() match {
+ case Some(b26) =>
+ a() match {
+ case Some(b27) =>
+ a() match {
+ case Some(b28) =>
+ a() match {
+ case Some(b29) =>
+ a() match {
+ case Some(b30) =>
+ println("yay")
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ }
+}
+