Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SBT use the Fast Scala Compiler (fsc)?

Tags:

scala

sbt

Does SBT make use of fsc?

For test purposes I am compiling a 500-line program on a fairly slow Ubuntu machine (Atom N270). Three successive compile times were 77s, 66s, and 66s.

I then compiled the file with fsc from the command line. Now my times were 80s, 25s, 18s. Better! That implies to me sbt is not using fsc. Am I right? If so, why doesn't it use it?

I may try getting sbt to explicitly use fsc to compile, though I am not sure I will figure out the config. Has anyone done this?

like image 876
Crosbie Avatar asked Sep 02 '10 07:09

Crosbie


People also ask

What does sbt compile do?

Compiles the main sources (in src/main/scala and src/main/java directories). Compiles and runs all tests. 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).

Which compiler is used in Scala?

Scala Native is a Scala compiler that targets the LLVM compiler infrastructure to create executable code that uses a lightweight managed runtime, which uses the Boehm garbage collector.

What is SBT interface?

The Oracle Secure Backup SBT interface enables you to use Recovery Manager (RMAN) to back up Oracle databases. All major tape drives and tape libraries in SAN, Gigabit Ethernet, and SCSI environments are supported.


3 Answers

This discussion made me realize I have been using sbt the wrong way.

Instead of (from the command line):

$ sbt compile
$ sbt test

..one should keep sbt running and treat it as the command prompt.

$ sbt
> compile
  ...
> test

It has the command history and even ability to dive back into OS command line. I wrote this 'answer' for others like me (coming from a Makefile mindset) that might not realize we're taking the pill all wrong. :)

(It's still slow, though.)

like image 83
akauppi Avatar answered Oct 14 '22 05:10

akauppi


SBT cannot benefit from the Fast Scala Compiler when you run it interactively (with or without using its continuous build mode) because the Scala compiler classes are loaded and get "warmed up" and JIT-ed, which is the entirety of fsc's advantage.

like image 12
Randall Schulz Avatar answered Oct 14 '22 04:10

Randall Schulz


At least for SBT 0.7.x the authors explain that it is not as fast as fsc, which caches the compiler instance (including the loaded libraries), rather than just the JITted compiler classes:

http://code.google.com/p/simple-build-tool/wiki/ChangeDetectionAndTesting

My experience also confirms that fsc is faster for full compiles, but does not automatically select what to recompile.

For SBT 0.10, I can find no docs whatsoever on this issue.

like image 2
Blaisorblade Avatar answered Oct 14 '22 05:10

Blaisorblade