lein uberjar much faster as lein run

507 views
Skip to first unread message

Cecil Westerhof

unread,
Apr 22, 2014, 9:33:58 AM4/22/14
to clo...@googlegroups.com
When using lein run, I get the following measurements:
 1 threads took   50292 milliseconds
 2 threads took   28797 milliseconds
 4 threads took   19531 milliseconds
 6 threads took   16973 milliseconds
 7 threads took   15761 milliseconds
 8 threads took   15071 milliseconds

While if I use lein uberjar && java -jar ..., I get:
 1 threads took   11983 milliseconds
 2 threads took    5778 milliseconds
 4 threads took    3102 milliseconds
 6 threads took    2500 milliseconds
 7 threads took    2288 milliseconds
 8 threads took    2319 milliseconds

​Why is lein run so much slower?

By the way: Leiningen is really a good tool. Only for that you could switch to Clojure. ;-)​



​And another question: how would I ​
​call the normal jar? Because when I do not distribute ​
​the jar, it pays not to make the standalone jar. 33K or 3.5M is quite a difference.​


--
Cecil Westerhof

Jony Hudson

unread,
Apr 22, 2014, 10:01:34 AM4/22/14
to clo...@googlegroups.com
I recall reading that `lein run` uses JVM options optimised for startup time, not performance - as it's intended for use in development, not production. I can't seem to find where I read that though ...


Jony

Lee Spector

unread,
Apr 22, 2014, 10:50:05 AM4/22/14
to clo...@googlegroups.com

On Apr 22, 2014, at 10:01 AM, Jony Hudson <jonye...@gmail.com> wrote:

> I recall reading that `lein run` uses JVM options optimised for startup time, not performance - as it's intended for use in development, not production. I can't seem to find where I read that though ...

Somebody with actual knowledge of what's under the hood will undoubtedly be able to say more (and maybe correct me :-), but I've been led to believe that if you want things to run fast (at the expense of possibly longer startup time) with "lein run" then you actually want to use "lein with-profile production run".

FWIW (not much) I'd prefer that that be the default, or that there be a somewhat more obvious/memorable syntax ("lein fast run"?).

In our limited testing "lein with-profile production run" did indeed make a big difference, sometimes producing a ~2x speedup. This isn't as big as the difference that Cecil's getting with the uberjar though... and if we could get the ~5x speedup that he seems to be getting from uberjar then that would be fantastic. I guess we ought to just try that, but I'd appreciate any insights that knowledgable people here could provide on this.

-Lee

Cecil Westerhof

unread,
Apr 22, 2014, 11:28:42 AM4/22/14
to clo...@googlegroups.com

​That gives:
 1 threads took   11811 milliseconds
 2 threads took    6015 milliseconds
 4 threads took    3155 milliseconds
 6 threads took    2567 milliseconds
 7 threads took    2356 milliseconds
 8 threads took    2218 milliseconds
 

So that is comparable to uberjar. I will use this in the future. Thanks.

--
Cecil Westerhof

Gary Trakhman

unread,
Apr 22, 2014, 11:30:00 AM4/22/14
to clo...@googlegroups.com


On Tue, Apr 22, 2014 at 10:01 AM, Jony Hudson <jonye...@gmail.com> wrote:
I recall reading that `lein run` uses JVM options optimised for startup time, not performance - as it's intended for use in development, not production. I can't seem to find where I read that though ...


Jony

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Miller

unread,
Apr 22, 2014, 11:34:38 AM4/22/14
to clo...@googlegroups.com
By default, lein run will use tiered compilation, which starts faster, but is not as fast. 

Reply all
Reply to author
Forward
0 new messages