Native image of SBT itself (Graal / GraalVM)

SBT is notoriously slow to start up. It would be great if it could come pre-packaged as a graal / graalvm native image.

I’m sure there are tons of roablocks to something like this, but maybe they can be overcome?

While I’m not familiar with the Graal or SBT internals, I am very familiar with the pain of a start sbt, run play app, edit code, reload page, wait for compilation etc cycle. etc.

If SBT could provide an “out of the box” native experience across platforms, ideally for both SBT itself and for scalac, then that would be an absolutely amazing win.

In fact, I suspect that many of the “scala is slow to compile” complaints out there are actually “it is slow to start sbt and then get my application compiled and running” complaints.

If the only thing blocking this for scalac is macros as indicated in [2], then providing a native experience out-of-the-box if you don’t use non-standard macros (which can be liberally defined - include commonly used published macros) could be a great incentive not to go macro-crazy.

Thoughts?

See also:

  1. Akka and Graal’s native image tool
  2. https://www.graalvm.org/docs/reference-manual/languages/scala/getting-started/
1 Like

sbt is designed to be an interactive build tool. I feel like too many people use it from the terminal as

$ sbt compile

One way to workaround it is to use something like cb372/sbt-client that will talk to sbt server via LSP. Chris’s thin client is written in Rust, so there’s no JVM spinup overhead.

Even if doing sbt compile is not the intended way of using it, shouldn’t that usage also be ok? As in: isn’t “sbt should be left as a long running process” essentially a cop-out?

I don’t think I could have made a better argument for getting sbt+scalac on graal stat ;)

I really don’t recommend it. Besides sbt’s loading, JITing Scala compiler to the optimum level takes a long time, so by doing sbt compile you’re paying for both the latency and throughput. To some degree, we have made a middle ground compromise by creating sbt server, which allows for thin clients. If people want to keep using terminal they just have to install a new program.

On the other hand, however, I’m not shooting down the idea of Graal either. If someone wants to research that and report their findings, I’d be happy to see the results.

Fair enough. But then calling sbt compile should produce a warning that you’re calling it wrong and either provide instructions right there or a link to a webpage describing the problem & solution.