Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is leiningen so slow when it starts?

I'm using lein repl to execute clojure repl in console. When I run it, it takes over 15 seconds. When I run java -cp clojure-1.6.0.jar clojure.main, it takes just a few seconds.

Why is lein repl so slow? Are there anyways to make it faster?

My env:

  • H/W: MacBookAir
  • O/S: Mac OS 10.9 Mavericks
  • CPU: i7
  • MEM: 8GB
like image 242
ntalbs Avatar asked Jul 31 '14 06:07

ntalbs


3 Answers

Leiningen starts two JVMs, and hooks them together. It's got to load extra stuff to do that. The prompt you type into is a different process from the Clojure process that evaluates your code. Leiningen also has to parse your project file and make sure that everything is set up as it requires, or go and get what's needed from the web if there's anything missing in your maven configuration directory. In the Leiningen sample project file there are some options that can speed up things a little bit, if you read through it carefully. I think that Leiningen having slow startup is just one of the facts of life right now.

More relevant information:

Improving startup time of Clojure REPL with Leiningen on the Raspberry Pi

Faster

like image 110
Mars Avatar answered Oct 18 '22 20:10

Mars


If you run lein repl from within a project directory, it will load your project's source files in addition to starting a repl. Even for a small project, this can add significant time if your source files reference external dependencies.

java -cp clojure-1.6.0.jar clojure.main won't load any project source files or dependencies.

like image 4
dbyrne Avatar answered Oct 18 '22 20:10

dbyrne


There are multiple ways to improve the startup time off lein. Documented here:

https://github.com/technomancy/leiningen/wiki/Faster

like image 4
tixel Avatar answered Oct 18 '22 19:10

tixel