Extremely slow compilation time with automatic SBT reload with the game! and scala -js

I have problems with SBT. My project is a fork: https://github.com/vmunier/play-with-scalajs-example and is currently pretty much identical. I added a few lines of code and imported the slides.

When I start the server using sbt, I start the project and it takes a lot of time. The same is true for the auto reload feature. I speak 2 to 3 minutes each time, for any code change. It is too slow even for SBT.

SBT version 0.13.0 Play version 2.1 Scala version 2.9.1 scatagates version 2.10 scalajs 0.2.4

This is the output in the SBT console

[info] Compiling 1 Scala source to /home/chobeat/git/2048-in-scala-js/scalajs/target/scala-2.10/classes... [info] Preoptimizing /home/chobeat/git/2048-in-scala-js/scalajvm/public/javascripts/scalajs/scalajs-example-preopt.js ... [warn] Referring to non-existent class scala_scalajs_test_JasmineTest [warn] Referring to non-existent method example_test_ScalaJSExampleTest$.expect__Lscala_scalajs_js_Any__Lorg_scalajs_jasmine_JasmineExpectation [warn] called from example_test_ScalaJSExampleTest$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp__V [warn] called from example_test_ScalaJSExampleTest$$anonfun$1$$anonfun$apply$mcV$sp$1.apply__V [warn] called from example_test_ScalaJSExampleTest$$anonfun$1$$anonfun$apply$mcV$sp$1.apply__O [warn] called from scala_Predef$.require__Z__Lscala_Function0__V [warn] called from scala_collection_Iterator$class.scala_collection_Iterator$class__copyToArray__Lscala_collection_Iterator__O__I__I__V [warn] called from scala_collection_AbstractIterator.copyToArray__O__I__I__V [warn] called from scala_collection_TraversableOnce$class.scala_collection_TraversableOnce$class__copyToArray__Lscala_collection_TraversableOnce__O__I__V [warn] called from scala_collection_AbstractTraversable.copyToArray__O__I__V [warn] called from scala_collection_TraversableOnce$class.scala_collection_TraversableOnce$class__toArray__Lscala_collection_TraversableOnce__Lscala_reflect_ClassTag__O [warn] called from scala_collection_AbstractTraversable.toArray__Lscala_reflect_ClassTag__O [warn] called from scala_collection_immutable_StringLike$class.scala_collection_immutable_StringLike$class__format__Lscala_collection_immutable_StringLike__Lscala_collection_Seq__T [warn] called from scala_collection_immutable_StringOps.format__Lscala_collection_Seq__T [warn] called from scala_collection_immutable_Range.description__p4__T [warn] called from scala_collection_immutable_Range.fail__p4__Lscala_Nothing [warn] called from scala_collection_immutable_Range.scala$collection$immutable$Range$$validateMaxLength__V [warn] called from scala_collection_immutable_Range.validateRangeBoundaries__Lscala_Function1__Z [warn] called from scala_collection_immutable_Range.foreach__Lscala_Function1__V [warn] called from scala_collection_TraversableOnce$class.scala_collection_TraversableOnce$class__foldLeft__Lscala_collection_TraversableOnce__O__Lscala_Function2__O [warn] called from scala_collection_AbstractTraversable.foldLeft__O__Lscala_Function2__O [warn] called from scala_collection_generic_TraversableForwarder$class.scala_collection_generic_TraversableForwarder$class__foldLeft__Lscala_collection_generic_TraversableForwarder__O__Lscala_Function2__O [warn] called from scala_collection_mutable_ListBuffer.foldLeft__O__Lscala_Function2__O [warn] called from scala_collection_immutable_ListSet$ListSetBuilder.result__Lscala_collection_immutable_ListSet [warn] called from scala_collection_immutable_ListSet$ListSetBuilder.result__O [warn] called from scala_collection_TraversableLike$class.scala_collection_TraversableLike$class__flatMap__Lscala_collection_TraversableLike__Lscala_Function1__Lscala_collection_generic_CanBuildFrom__O [warn] called from scala_collection_immutable_Stream.flatMap__Lscala_Function1__Lscala_collection_generic_CanBuildFrom__O [warn] called from scala_collection_immutable_Stream$StreamBuilder.result__Lscala_collection_immutable_Stream [warn] called from scala_collection_immutable_Stream$StreamBuilder.result__O [warn] called from scala_collection_generic_GenericCompanion.empty__Lscala_collection_GenTraversable [warn] called from scala_collection_generic_GenericSetTemplate$class.scala_collection_generic_GenericSetTemplate$class__empty__Lscala_collection_generic_GenericSetTemplate__Lscala_collection_GenSet [warn] called from scala_collection_AbstractSet.empty__Lscala_collection_GenSet [warn] called from scala_collection_immutable_Set$Set2.empty__Lscala_collection_Set [warn] called from scala_collection_SetLike$class.scala_collection_SetLike$class__newBuilder__Lscala_collection_SetLike__Lscala_collection_mutable_Builder [warn] called from scala_collection_AbstractSet.newBuilder__Lscala_collection_mutable_Builder [warn] called from scala_collection_IterableLike$class.scala_collection_IterableLike$class__take__Lscala_collection_IterableLike__I__O [warn] called from scala_collection_AbstractIterable.take__I__O [warn] called from scala_collection_mutable_ListBuffer.$$plus$plus$eq__Lscala_collection_TraversableOnce__Lscala_collection_mutable_ListBuffer [warn] called from scala_collection_mutable_ListBuffer.$$plus$plus$eq__Lscala_collection_TraversableOnce__Lscala_collection_generic_Growable [warn] called from scala_collection_TraversableOnce$class.scala_collection_TraversableOnce$class__to__Lscala_collection_TraversableOnce__Lscala_collection_generic_CanBuildFrom__O [warn] called from scala_collection_AbstractIterator.to__Lscala_collection_generic_CanBuildFrom__O [warn] called from scala_collection_TraversableOnce$class.scala_collection_TraversableOnce$class__toSet__Lscala_collection_TraversableOnce__Lscala_collection_immutable_Set [warn] called from scala_collection_AbstractTraversable.toSet__Lscala_collection_immutable_Set [warn] called from scala_runtime_ScalaRunTime$.init___ [warn] called from scala_scalajs_js_JavaScriptException.hashCode__I [warn] called from java_lang_Object.toString__T [warn] called from scalajs-corejslib.js [warn] involving instantiated classes: [warn] example_test_ScalaJSExampleTest$$anonfun$1$$anonfun$apply$mcV$sp$1 [warn] scala_Predef$ [warn] scala_collection_immutable_StreamIterator [warn] scala_collection_immutable_HashSet$HashSet1 [warn] scala_collection_immutable_StringOps [warn] scala_collection_immutable_Range [warn] scala_collection_mutable_ListBuffer [warn] (already seen, not repeating call stack) [warn] scala_collection_immutable_ListSet$ListSetBuilder [warn] (already seen, not repeating call stack) [warn] scala_collection_immutable_Stream$Cons [warn] (already seen, not repeating call stack) [warn] scala_collection_immutable_Stream$StreamBuilder [warn] scala_collection_Traversable$ [warn] (already seen, not repeating call stack) [warn] scala_collection_immutable_Set$Set2 [warn] (already seen, not repeating call stack) [warn] scala_collection_Iterator$$anon$2 [warn] scala_collection_immutable_Nil$ [warn] (already seen, not repeating call stack) [warn] scala_scalajs_js_JavaScriptException [warn] java_lang_Object [warn] Referring to non-existent method example_test_ScalaJSExampleTest$.describe__T__Lscala_Function0__V [warn] called from example_test_ScalaJSExampleTest$.init___ [warn] exported to JavaScript with @JSExport [warn] Referring to non-existent method example_test_ScalaJSExampleTest$.it__T__Lscala_Function0__V [warn] called from example_test_ScalaJSExampleTest$.init___ [warn] exported to JavaScript with @JSExport 
+8
scala playframework sbt
source share
1 answer

Since you use scalatags and scala -js, which are very heavily used compilers, you will have much longer compilation time than usual when changing code that needs to be changed. Some things you can do to mitigate this are upgrading to the latest versions of Play (2.2.2), sbt (0.13.1), and scala (2.10.3), which have all made performance improvements regarding compile time. If you are not using incremental compilation yet, I would suggest doing this (play ~ run or play ~ test-quick). Also check your memory limits (Xmx and MaxPermGen) and use the latest JDK (7 or 8).

Using the latest versions, I was able to get these points:

"play test" assembled the application and tests and completed all tests in 173 seconds

"play run" takes 10 seconds to launch a web application after it has already been compiled

"sbt run" takes 10 seconds to start a web application after it has already been compiled

"sbt test" takes 10-25 seconds

"Game Test" takes 10-17 seconds

"sbt compile" takes ~ 20 seconds after cleaning

These times were achieved on a Macbook Pro Retina with SBT_OPTS = "- Xmx2048m" in .sbtconfig

+2
source share

All Articles