Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Scala's-SBT is too slow

Tags:

scala

sbt

I am facing slowness at many places while working with sbt

  1. Importing SBT Project in Intellij -- approx(8-10 minutes).
  2. Indexing in Intellij of SBT Project.
  3. sbt (In terminal this command takes -- approx(2-3 minutes)).
  4. compile (In sbt shell this command takes -- approx(3-5 minutes)).
    5.Whenever I modify build.sbt file then project refresh takes 3-4 minutes.

There are more places i need to check but above specified points i am facing frequently.

Is this problem related to SBT or Scala ?, If yes How to resolve the same

Note : I have good internet connection so this cannot be network issue.

My Scala Class file :

import org.scalatest._  class TaskManagerSpec extends FlatSpec with Matchers {    "An empty tasks list" should "have 0 tasks due today" in {     val tasksDueToday = TaskManager.allTasksDueToday(List())     tasksDueToday should have length 0   }  } 

build.sbt

name := "tasky" version := "0.1.0" scalaVersion := "2.11.6" resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases" libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test" 
like image 293
Neeraj Jain Avatar asked Sep 14 '16 05:09

Neeraj Jain


Video Answer


1 Answers

SBT is slow because compiles internal code that is done in Scala and Scala compilation is slow because is a complex language (but once Scala is compiled is a lot faster at runtime)

You can give SBT a boost when using SBT 1.x version with the SBT server. The SBT server allows you to use just one SBT instance shared between command line and the IDE. This is pretty useful, more info here: https://www.scala-sbt.org/1.x/docs/sbt-server.html

Also considere using other build tools that are lighter, like PANTS, that is based on Python which is interpreted and a lot faster. More info at: https://www.pantsbuild.org/

NOTE: the PANTS documentation and community is not as extensive as with SBT but is worth the try, there are amazing things that can be done with PANTS.

NOTE2: if your code base is large it will still take a lot of time to compile/build, so considere to arrange your code and artifacts as incremental/cached pieces/subprojects to see a real boost.

like image 126
Carlos Saltos Avatar answered Oct 02 '22 21:10

Carlos Saltos