I'd like to get more guidance on how to specify :jvm-opts for maximum 
performance. I've received some help on this topic from people on this list in 
the past (thanks!), but I'm pretty sure that I'm still not doing things right.

I'm almost always interested in maximum performance for long-running, 
compute-intensive and memory-intensive processes, almost never caring much at 
all about startup time or anything else.

I also run my code on different machines, with different numbers of cores and 
amounts of memory, and would prefer to be able to put something in my 
project.clj that will do something reasonable regardless of what machine it's 
running on.

I run my code with "lein run", and I'd like whatever I need to "run fast" to be 
in project.clj.

I don't know a lot about JVM options, and I've tried to figure out what to 
specify for :jvm-opts by asking questions here and web searches, but I'm not at 
all confident that I'm doing it right yet. And because my systems are also 
stochastic, it's not easy for me to do timing tests on the options I've tried. 

I think there are options relevant to memory and also garbage collection and 
maybe also compilation... and what else? I wish there was a simple switch to 
get maximum performance of the sort I've outlined here (or at least a 
reasonable stab at it), but I gather that there isn't.

Anyway, here's what I've been using recently, which just deals with memory and 
GC (and maybe not in the best way):

  :jvm-opts ~(let [mem-to-use (long (* (.getTotalPhysicalMemorySize
                                         
(java.lang.management.ManagementFactory/getOperatingSystemMXBean))
                                       0.8))]
               [(str "-Xmx" mem-to-use)
                (str "-Xms" mem-to-use)
                "-XX:+UseG1GC"])

After seeing Alex's post I thought that maybe I should add "-server", as 
follows:

  :jvm-opts ~(let [mem-to-use (long (* (.getTotalPhysicalMemorySize
                                         
(java.lang.management.ManagementFactory/getOperatingSystemMXBean))
                                       0.8))]
               [(str "-Xmx" mem-to-use)
                (str "-Xms" mem-to-use)
                "-XX:+UseG1GC"
                "-server"])

Is that right? Does it make sense? What does "-server" do? Also, should I also 
be using "^:replace"?

I've looked in 
https://github.com/technomancy/leiningen/blob/master/sample.project.clj in 
hopes that this would say more about this stuff, but it doesn't say anything 
about -server or ^:replace.

Looking into the compilation options, it looks from 
https://github.com/technomancy/leiningen/wiki/Faster that I should be 
specifying:

:jvm-opts ^:replace []

This is also familiar to me from some earlier discussions. But how would I 
combine this with the memory/GC/server(?) options above?

A guess would be that maybe I should do this:

  :jvm-opts ^:replace
              ~(let [mem-to-use (long (* (.getTotalPhysicalMemorySize
                                         
(java.lang.management.ManagementFactory/getOperatingSystemMXBean))
                                       0.8))]
               [(str "-Xmx" mem-to-use)
                (str "-Xms" mem-to-use)
                "-XX:+UseG1GC"
                "-server"
                "-XX:-TieredCompilation"])

Note that this guess involves changing a + to a - in the last line, which was 
suggested for the opposite purpose at 
https://github.com/technomancy/leiningen/wiki/Faster -- but I don't know if 
it's legitimate.

Is this a reasonable thing to do to get maximum performance for long-running, 
compute-intensive and memory-intensive processes?

Is the tiered compilation thing maybe already done by including "-server"?

I'm probably at least somewhat confused about several different issues here...

Any help or pointers would be appreciated.

Thanks,

 -Lee




> On May 14, 2015, at 3:47 PM, Alex Miller <a...@puredanger.com> wrote:
> 
> Gah. Meant in project.clj:
> 
> :jvm-opts ^:replace ["-server"]  ;; maybe also set max heap with  "-Xmx1g" in 
> there
> 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to