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

4

17

I got a Rasperry Pi 512 MB version (late 2012) and installed the Developer Preview of Java SE 8 for ARM on it. When I create a new Clojure project with Leiningen and launch the nREPL by doing lein repl it takes a bit more than two minutes (roughly 130 - 140 seconds) until the REPL has been initialized and can be used.

When launching the JAR file directly java -jar clojure-1.4.0/clojure-1.4.0 the REPL starts up in 25s.

I'm using fast class 10 SD cards (SanDisk Extreme with up to 30 MB/s). How come that the difference between using Leiningen with nRepl vs launching the JAR file is so big? What could be done to improve the startup time with Leiningen for the Raspberry Pi?

Butchery answered 26/12, 2012 at 11:48 Comment(6)
lein repl checks dependencies, builds the project and prepares auto completion and other shenanigans like that. You could try to do clever things like keeping a JVM with Clojure loaded to run leiningen on around, but I'm not sure how much that would actually reduce the startup time. I suppose ideally, you should just try to not run lein repl very often.Campman
Yes, that's what I've been thinking as well. I've seen similar discussions on the Clojure mailing list, but on a desktop PC or notebook the slowdown is not as bad as it is on the Raspberry Pi. Common Lisp REPL starts up in 1s, the performance overhead for Java and classpath scanning is pretty heavy. Not sure if Clojure is such a good development platform for embedded devices.Butchery
raju-bitter, I'm curious of what Common-Lisp implementation are you using in the Pi...Betroth
GNU CLISP 2.49 (2010-07-07), it's in the repository for Wheezy. Just did a sudo apt-get install clisp.Butchery
This seems to explain some of it nicholaskariniemi.github.io/2014/02/25/…Suitable
See also dev.clojure.org/display/design/Improving+Clojure+Start+TimeWillhite
C
2

Also try grenchman: Fast invocation of Clojure code over nREPL.

Cami answered 13/11, 2013 at 23:37 Comment(0)
D
1

You can try drip which wraps the java command and prepare a fresh jvm waiting in the background.

Druce answered 8/1, 2013 at 22:40 Comment(1)
Thanks, I'll try that and report the results here.Butchery
S
1

It seems the slow startup of clojure in general is the loading of core and various other things discussed here:

http://blog.ndk.io/solving-clojure-boot-time.html

Suitable answered 10/12, 2014 at 12:53 Comment(0)
J
0

Actually the Leiningen starts in it's own JVM and then nests the project's vm inside it.
Then it checks deps, figures out the changes and so on.

You can avoid vm nesting with the trampoline task of lein like so:
lein trampoline repl

But this command requires the lein to be called in a project directory

Joesphjoete answered 10/12, 2014 at 12:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.