Skip to content

Instantly share code, notes, and snippets.

@LIttleAncientForestKami
Last active April 23, 2017 13:12
Show Gist options
  • Save LIttleAncientForestKami/8eb4e429b9ae36e40ff1095d30cc5735 to your computer and use it in GitHub Desktop.
Save LIttleAncientForestKami/8eb4e429b9ae36e40ff1095d30cc5735 to your computer and use it in GitHub Desktop.
Ubuntu Xenial Sun(Oracle) Hotspot JDK 1.8.0_101-b13 Idea 17 Ultimate 64

What is here

Links for more, along with default config and others, that I either came across and rejected, or came across and am pondering.

Default file

Start with this, it's default for a reason.

  • -server - there are client and server compilers in the JDK. Client is about fast start-up, server is about long running (simplification). Since JDK 7 though we have -XX:+TieredCompilation, so...
  • -Xms128m - 128 MB for initial heap size.
  • -Xmx512m - 512 MB for maximum heap size.
  • -XX:ReservedCodeCacheSize=240m - sets JIT compiler code cache, to avoid "CodeCache is full. Compiler has been disabled." cases.
  • -XX:+UseConcMarkSweepGC - mostly concurrent GC algorithm for old space. Since I want responsiveness, let's keep it in.
  • -XX:SoftRefLRUPolicyMSPerMB=50 - soft refs are flushed 50ms per free MB in -Xmx / -Xms (-client / -server) after last touch.
  • -ea enables assert from JDK 4. While rarely used, it's part of the JDK. Perf effects for on/off are unknown (to me).
  • -Dsun.io.useCanonCaches=false - disable cache for canonical paths (simplification: symlinks now up to date)
  • -Djava.net.preferIPv4Stack=true - even when IPv6 is available, use v4 when networking.
  • -XX:+HeapDumpOnOutOfMemoryError - if OOM happens, dump the heap as binary in default location (OS dependent, but look in IDE dir or wherever you launched it, if launched from console)
  • -XX:-OmitStackTraceInFastThrow - when you develop, you want your stack known
  • -Dawt.useSystemAAFontSettings=lcd - uses system anti-aliasing settings for font, adjusted to LCD. Other interesting option is
  • -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine

GC logging - first change

While Peter Lawrey said Idea is mostly file based, GC logging can verify this and is a must have either way.

  • -Xloggc:/home/tammo/.IntelliJIdea2017.1/gc.log - log to file (with path)
  • -XX:+UseGCLogFileRotation - rotate log daily
  • -XX:NumberOfGCLogFiles=10 - log-rotation requires >0 number here
  • -XX:+PrintGCTimeStamps - in ms since app started
  • -XX:+PrintGCDateStamps - with dates (human readable)
  • -XX:+PrintGCDetails - main logging flag
  • -XX:+PrintReferenceGC - times for weak, JNI, etc. refs processing
  • -XX:+PrintGCCause - why GC happened (alloc fail, System.gc() call...)
  • -XX:+PrintPromotionFailure - if it happens, prints more info

Logging to file instead of console, with log rotation and minimum details. Refs are a must since I changed their setting from default. Promotion failure to see if sizing of heap needs adjustments, same with GC details and causes.

Links

  1. Code Cache: https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/codecache.htm
  2. HotSpot VM Options: http://www.oracle.com/technetwork/articles/java/vmoptions-jsp-140102.html
  3. Client and Server compilers: http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#compiler_types
  4. Fast throw stack trace optimization: http://jawspeak.com/2010/05/26/hotspot-caused-exceptions-to-lose-their-stack-traces-in-production-and-the-fix/

Soft refs

Good for caches, they are cleared some time (default: 1 second) after they are touched last. Their clearance happens before OOM (OOM won't be thrown if you have soft refs to clear). Flag for their clearing silently depends on whether C1 or C2 compilers are in use (client is C1, IIRC

:check: how are things with tiered compilation on?

  1. Soft refs flushing: http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_softrefs
  2. Jeremy Manson about flushing algo: http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html
  3. Question (answered) about it: https://community.oracle.com/thread/1543565
  4. JVM code researched in SO answer: http://stackoverflow.com/questions/9932398/how-are-softreferences-collected-by-jvms-in-practice

Canonical cache

One of the two system properties for enabling/disabling performance optimisation for file names canonicalization.

See this puzzler: http://konigsberg.blogspot.com/2009/10/symbolic-puzzler.html The test success or failure depend on JVM starting flag, our useCanonCache exactly. It either stores first call result for 30 seconds or it doesn't. If you update symlink, you won't get fresh data, but cached one instead (if default value is used).

  1. Puzzler: http://konigsberg.blogspot.com/2009/10/symbolic-puzzler.html
  2. It's answer: http://konigsberg.blogspot.com/2009/10/answer-to-symbolic-puzzler.html
  3. SO user stumbled upon this problem: http://stackoverflow.com/questions/7479198/canonical-file-path-in-java-optimization-problem

Fonts anti-aliasing

  1. NetBeans FAQ on it: http://wiki.netbeans.org/FaqFontRendering
  2. Piotr Wittchen makes a wrapper runner to make Intellij look better on Ubuntu: http://wiki.netbeans.org/FaqFontRenderinghttp://blog.wittchen.biz.pl/adjusting-look-feel-of-intellij-idea-and-android-studio-on-ubuntu/
  3. Oracle Trails on anti-aliasing: http://docs.oracle.com/javase/tutorial/2d/text/renderinghints.html

Other folks use

https://gist.github.com/P7h/4388881 https://gist.github.com/EdwardBeckett/4bbb1bcaad3f900e7305 https://gist.github.com/zafarella/43bc260c3c0cdc34f109

IDEA tuning basics

https://www.jetbrains.com/help/idea/2017.1/tuning-intellij-idea.html#d427984e92

-server
-Xms128m
-Xmx512m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Dawt.useSystemAAFontSettings=lcd
-Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine
-server
-Xms128m
-Xmx512m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Dawt.useSystemAAFontSettings=lcd
-Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine
-Xloggc:/home/tammo/.IntelliJIdea2017.1/gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintReferenceGC
-XX:+PrintGCCause
-XX:+PrintPromotionFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment