It seems to me that SBT takes up too much CPU time just by observing file changes. I know this post, but the author there was mixing IDE processor time with SBT processor time; I do not have an IDE.
I am developing a Play project in Scala with approximately 370 Scala files divided into 5 modules.
Running sbt with ~ run consumes about 70-90% of the processor on my MacBook Pro (mid-2012). I don’t have an IDE, I don’t edit any files, I don’t browse the browser on the server ... Just inactivity with ~ run (and viewing the file system) takes 70-90% of the CPU according to Activity Monitor.
After I stood idle for a while, I started VisualVM; It shows itself and another JVM process:
Details of the xsbt process (for each VisualVM):
PID: 56661
Host: localhost
Main class: xsbt.boot.Boot
Arguments: -Dhttp.port=9001 -Dhttps.port=9443 -Djsse.enableSNIExtension=false -Dhazelcast.config=conf/hazelcast-dev.xml -Dlogger.file=conf/logback-dev.xml -Dconfig.file=conf/passwords/local-dev.conf
JVM: Java HotSpot(TM) 64-Bit Server VM (25.121-b13, mixed mode)
Java: version 1.8.0_121, vendor Oracle Corporation
Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
JVM Flags: <none>
Heap dump on OOME: disabled
JVM arguments:
-Xms1024m
-Xmx1024m
-XX:ReservedCodeCacheSize=128m
-XX:MaxMetaspaceSize=256m
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Here are some details from VisualVM where time goes:
Is 80% of the CPU used - and the fans run most of the time - is it reasonable while sbt is idling? Seems really tall. Any strategies to reduce it?
PS: When sbt is only on the command line (without looking at the file changes), Activity Monitor shows about 5% of CPU usage.
PPS: concurrentRestrictions in Global += Tags.limit(Tags.Test, 4)
, . , , . , , . , Activity Monitor - ~ 80% , CPU idleAwaitWork
, ConcurrentRestrictions$$anon$4.take
SourceModificationWatch$.watch
.