When I run the Bloop compile command it fails with stack overflow errors which was a problem I ran into when using SBT. To fix it I created a .sbtopts file and increased the -J-XX:MaxMetaspaceSize, -J-Xss and -J-Xmx options to give the compiler some more juice to make it through what I'm guessing is some unoptimized implicit resolution code (shapeless, etc). Is there a way to set the same options with Bloop or configure SBT so the SBT plugin properly picks up and gives those setting to Bloop?
You can only modify the JVM options when you start up bloop鈥檚 server, so there鈥檚 no way to change them in the fly (this is a limitation of the JVM).
Tip: use -XX:MaxInlineLevel:20 if you wanna have faster compilation in the server.
@jvican thanks for the quick response! If I installed Bloop via Homebrew where's the correct place to change those settings? Or should I install it another way to have more control over those settings?
That sounds like something we should add to the docs, @Duhemm should be able to tell you where :smile:
By the way, Nate, now that I re-read your description: you should not be required to increase the metaspace and the xmx with bloop as much as you do with sbt (bloop is much lightweight than sbt is).
I recommend you try it with a more reasonable set of jvm options first (if your app doesn't have more than ~200.000 LOC you don't want to go higher than 2g).
When you want to run a Play project, it is necessary to pass in the path to the configuration file. In my situation, I had to add -Dconfig.file=conf/application.conf to options in the JVM settings.
Another case where changing the configuration file is undesirable is when you want to attach a debugger and need to specify -agentlib.
Given that it is common to set JVM options on-the-fly, what do you think about adding the CLI parameter -J/--jvm-option?
@tindzk You can add JVM options in the CLI directly by putting all the application options after -- (this is the standard way of doing this with CLI apps and build tools). For example, our developer documentation explains how you can use the debugger with bloop:
bloop run frontend -- -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
Maybe we should add this to our FAQ.
I tried that, but it does not work for me:
$ bloop run -m play.core.server.ProdServerStart web -- -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
[E] Bad root server path: /home/tim/dev/project/-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
@tindzk web is an argument to the main class? if so it should also go after --.
$ bloop run -m play.core.server.ProdServerStart web -- -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
No, web is the project name.
Hmm, I'm taking a look at this soon and updating the docs.
Looking at ps, the -agentlib option is placed after the entry point and therefore Play interprets it.
The command should be:
java [...] -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 play.core.server.ProdServerStart
Instead of:
java [...] play.core.server.ProdServerStart -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
As a workaround, I am using JAVA_TOOL_OPTIONS as per this comment.
Is there a way to set the same options with Bloop or configure SBT so the SBT plugin properly picks up and gives those setting to Bloop?
@natevecc In 1.2.0, a .jvmopts file will be read in the installation directory of bloop when the server is run via bloop server (the recommended way of launching it). I'll be closing this ticket when the release is out.
Also, I don't remember having said this before, but you can modify javaOptions in Test or javaOptions in run (see https://www.scala-sbt.org/1.x/docs/Forking.html) in order to persist the java options that need to be used when running/testing to the bloop configuration file. You can inspect whether the java options are added or not by looking at the value of the platform field in the corresponding bloop configuration file.