Reputation: 9051
I'm learning the clojure luminus web framework. In the tutorial, I can run my app simply with lein run
in the project directory. And of course, I could compile the project with lein uberjar
, and run it with java -jar myapp.jar
. I've found that the java -jar myapp.jar
approach slightly faster during load test.
Question:
Is clojure code compiled when it is run in the REPL
?
Why run the jar file faster than the lein run
approach? (Please correct me if I was wrong.)
Is it possible to open a REPL
when running the compiled jar
file?
Upvotes: 4
Views: 443
Reputation: 91554
(nrepl/start-server :port port :bind "127.0.0.1")
Upvotes: 2
Reputation: 13175
There are at least two major factors:
JVM parameters might be different and they are controller either by lein config when you use lein run
or directly by you if you run it manually via java ...
. Parameters like HotSpot compiler options, memory and GC configuration. You can use tools like jstat
, jinfo
and jconsole
to check the effective JVM settings.
Check your lein profiles and which is run in either case. You might run your application in two different app configuration changing things like ring's hot code reloading, different set of ring middlewares (check files in env
directory of your project) etc.
Upvotes: 0
Reputation: 6036
There are many reasons why this is happening can exists. The most obvious is a TiredCompilation option which is used by lein. It changes JIT behavior, so it can affect benchmark results significantly.
You can disable changing JVM options by lein:
:jvm-opts ^:replace []
Or
$ export LEIN_JVM_OPTS=
See lein wiki.
Upvotes: 1