I'm using Scala 2.9.0.final on Ubuntu 11.04. Starting scala from the command line takes about 20 seconds before a prompt appears.
I realize I should expect some delay because it has to lead compiler JAR files, but I have a hard time believing that it should be 20 seconds -- I worry I may have something configured wrong.
EDIT
So I tried jstack and it gives a long output that is above my head. I see one thread waiting on a mutex. But looking at the output from time
:
21.96s user 0.66s system 135% cpu 16.711 total
It would seem that it spent a decent amount of cycles on both cores... so maybe it's not just blocking on a mutex for that time?
2011-07-28 11:45:02
Full thread dump OpenJDK 64-Bit Server VM (20.0-b11 mixed mode):
"Attach Listener" daemon prio=10 tid=0x00000000023ea000 nid=0x19a9 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Thread-0" prio=10 tid=0x00007f7768304800 nid=0x19a8 runnable [0x00007f776cd92000]
java.lang.Thread.State: RUNNABLE
at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.<init>(Growable.scala:48)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:128)
at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:242)
at scala.collection.mutable.WrappedArray.toList(WrappedArray.scala:33)
at scala.collection.immutable.List$.apply(List.scala:434)
at scala.Option.toList(Option.scala:231)
at scala.tools.nsc.util.DirectoryClassPath.asURLs(ClassPath.scala:321)
at scala.tools.nsc.util.ClassPath.sortString(ClassPath.scala:284)
at scala.tools.nsc.util.ClassPath.hashCode(ClassPath.scala:289)
at scala.collection.mutable.FlatHashTable$HashUtils$class.elemHashCode(FlatHashTable.scala:349)
at scala.collection.mutable.HashSet.elemHashCode(HashSet.scala:39)
at scala.collection.mutable.FlatHashTable$class.containsEntry(FlatHashTable.scala:109)
at scala.collection.mutable.HashSet.containsEntry(HashSet.scala:39)
at scala.collection.mutable.HashSet.contains(HashSet.scala:55)
at scala.collection.GenSetLike$class.apply(GenSetLike.scala:44)
at scala.collection.mutable.HashSet.apply(HashSet.scala:39)
at scala.collection.SeqLike$$anonfun$distinct$1.apply(SeqLike.scala:505)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.SeqLike$class.distinct(SeqLike.scala:504)
at scala.collection.immutable.List.distinct(List.scala:45)
at scala.tools.util.PathResolver$Calculated$.containers(PathResolver.scala:206)
- locked <0x00000000faba8098> (a scala.tools.util.PathResolver$Calculated$)
at scala.tools.util.PathResolver.containers(PathResolver.scala:228)
at scala.tools.util.PathResolver.result(PathResolver.scala:231)
- locked <0x00000000faba8050> (a scala.tools.util.PathResolver)
at scala.tools.nsc.backend.JavaPlatform$class.classPath(JavaPlatform.scala:18)
at scala.tools.nsc.Global$$anon$2.classPath(Global.scala:54)
- locked <0x00000000faba7ff0> (a scala.tools.nsc.Global$$anon$2)
at scala.tools.nsc.backend.JavaPlatform$class.rootLoader(JavaPlatform.scala:19)
at scala.tools.nsc.Global$$anon$2.rootLoader(Global.scala:54)
at scala.tools.nsc.Global$$anon$2.rootLoader(Global.scala:54)
at scala.tools.nsc.Global.rootLoader(Global.scala:57)
at scala.tools.nsc.symtab.Definitions$definitions$.RootClass(Definitions.scala:138)
- locked <0x00000000faba5620> (a scala.tools.nsc.symtab.Definitions$definitions$)
at scala.tools.nsc.symtab.Definitions$definitions$.EmptyPackage(Definitions.scala:141)
- locked <0x00000000faba5620> (a scala.tools.nsc.symtab.Definitions$definitions$)
at scala.tools.nsc.symtab.Definitions$definitions$.EmptyPackageClass(Definitions.scala:142)
- locked <0x00000000faba5620> (a scala.tools.nsc.symtab.Definitions$definitions$)
at scala.tools.nsc.symtab.Definitions$definitions$.init(Definitions.scala:804)
at scala.tools.nsc.Global$Run.<init>(Global.scala:693)
at scala.tools.nsc.interpreter.IMain.scala$tools$nsc$interpreter$IMain$$_initialize(IMain.scala:120)
at scala.tools.nsc.interpreter.IMain$$anonfun$initialize$1.apply$mcZ$sp(IMain.scala:154)
at scala.tools.nsc.interpreter.IMain$$anonfun$initialize$2.apply(IMain.scala:154)
at scala.tools.nsc.interpreter.IMain$$anonfun$initialize$2.apply(IMain.scala:154)
at scala.concurrent.ThreadRunner$$anon$2$$anonfun$run$2.apply(ThreadRunner.scala:45)
at scala.concurrent.ThreadRunner.scala$concurrent$ThreadRunner$$tryCatch(ThreadRunner.scala:31)
at scala.concurrent.ThreadRunner$$anon$2.run(ThreadRunner.scala:45)
at java.lang.Thread.run(Thread.java:679)
"Low Memory Detector" daemon prio=10 tid=0x00007f77680b9000 nid=0x1996 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread1" daemon prio=10 tid=0x00007f77680b6800 nid=0x1995 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread0" daemon prio=10 tid=0x00007f77680b3800 nid=0x1994 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" daemon prio=10 tid=0x00007f77680b2000 nid=0x1993 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Finalizer" daemon prio=10 tid=0x00007f7768092800 nid=0x1992 in Object.wait() [0x00007f776e27c000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000fb2d82d0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:133)
- locked <0x00000000fb2d82d0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:149)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)
"Reference Handler" daemon prio=10 tid=0x00007f7768091000 nid=0x1991 in Object.wait() [0x00007f776e37d000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000fb2d8370> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
- locked <0x00000000fb2d8370> (a java.lang.ref.Reference$Lock)
"main" prio=10 tid=0x0000000001db4800 nid=0x198d in Object.wait() [0x00007f7775067000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000fab8d110> (a scala.concurrent.SyncVar)
at java.lang.Object.wait(Object.java:502)
at scala.concurrent.SyncVar.get(SyncVar.scala:22)
- locked <0x00000000fab8d110> (a scala.concurrent.SyncVar)
at scala.concurrent.ThreadRunner$$anonfun$submit$1.apply(ThreadRunner.scala:48)
at scala.Function0$class.apply$mcZ$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcZ$sp(AbstractFunction0.scala:12)
at scala.tools.nsc.interpreter.IMain.global(IMain.scala:162)
- locked <0x00000000fb2d8580> (a scala.tools.nsc.interpreter.ILoop$ILoopInterpreter)
at scala.tools.nsc.interpreter.JLineCompletion.<init>(JLineCompletion.scala:17)
at scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:791)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:807)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:67)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
"VM Thread" prio=10 tid=0x00007f776808a000 nid=0x1990 runnable
"GC task thread#0 (ParallelGC)" prio=10 tid=0x0000000001dc0000 nid=0x198e runnable
"GC task thread#1 (ParallelGC)" prio=10 tid=0x0000000001dc1800 nid=0x198f runnable
"VM Periodic Task Thread" prio=10 tid=0x00007f77680bb800 nid=0x1997 waiting on condition
JNI global references: 1010
The Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program.
Starts the Scala interpreter with a classpath including the compiled sources and all dependencies. To return to sbt, type :quit, Ctrl+D (Unix), or Ctrl+Z (Windows).
Scala REPL is a command-line tool for the expression, evaluation, and execution of small code snippets. The acronym REPL stands for “Read-Evaluate-Print-Loop”. Similar to Java Shell, Scala REPL is very useful to newcomers and to those who want to experiment with new libraries or language features.
Answer: Use the console or consoleQuick commands inside the sbt shell: Type console to start a REPL session from inside SBT. This (a) compiles your Scala project and then (b) starts a REPL session. Type consoleQuick if you don't want to compile your project before starting a REPL session inside of sbt.
The startup time will be reduced in the upcoming 2.9.1 release. If yu want to you can already check it out by downloading the RC here : http://www.scala-lang.org/downloads
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With