tutorial starter run play instalar framework scala playframework sbt

starter - ¡Tiempo de compilación extremadamente lento con la recarga automática SBT usando el juego! y scala-js



play framework starter (1)

Estoy teniendo problemas con SBT. Mi proyecto es un tenedor de esto: https://github.com/vmunier/play-with-scalajs-example y por el momento es prácticamente idéntico. Solo agregué algunas líneas de código y scalatags importados.

Cuando abro el servidor con sbt, ejecuto el proyecto y toma mucho tiempo. Lo mismo es cierto para la función de recarga automática. Estoy hablando de 2 a 3 minutos cada vez, por cualquier cambio en el código. Esto es demasiado lento incluso para SBT.

SBT Versión 0.13.0 Reproducir Versión 2.1 Scala versión 2.9.1 scalatags versión 2.10 scalajs 0.2.4

Este es el resultado en la consola SBT

[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


Debido a que está utilizando scalatags y scala-js, que son bibliotecas muy intensivas en el compilador, tendrá tiempos de compilación mucho más largos de lo habitual cuando modifique el código que requiere cambios. Algunas cosas que puede hacer para mitigar esto son la actualización a las últimas versiones de Play (2.2.2), sbt (0.13.1) y scala (2.10.3) que han mejorado el rendimiento con respecto al tiempo de compilación. Si aún no está utilizando las compilaciones incrementales, le sugiero que lo haga (play ~ run o play ~ test-quick). También verifique sus límites de memoria (Xmx y MaxPermGen) y que esté usando la última versión del JDK (ya sea 7 u 8).

Usando las últimas versiones pude obtener estos tiempos:

"prueba de juego" compiló la aplicación y las pruebas y ejecutó todas las pruebas en 173 segundos

"play run" toma 10 segundos para iniciar la aplicación web después de que ya se haya compilado

"ejecutar sbt" lleva 10 segundos para iniciar la aplicación web después de que ya se haya compilado

La "prueba sbt" demora entre 10 y 25 segundos

"prueba de juego" toma 10-17 segundos

"sbt compile" tarda ~ 20 segundos después de la limpieza

Estos tiempos se lograron en una Macbook Pro Retina con SBT_OPTS = "- Xmx2048m" en .sbtconfig