diff --git a/templates/jvm.options.j2 b/templates/jvm.options.j2 index 9832782..dd908d7 100644 --- a/templates/jvm.options.j2 +++ b/templates/jvm.options.j2 @@ -41,6 +41,28 @@ -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly +## G1GC Configuration +# NOTE: G1GC is only supported on JDK version 10 or later. +# To use G1GC uncomment the lines below. +# 10-:-XX:-UseConcMarkSweepGC +# 10-:-XX:-UseCMSInitiatingOccupancyOnly +# 10-:-XX:+UseG1GC +{% if es_version is version('7.3.0', '<=') %} +# 10-:-XX:InitiatingHeapOccupancyPercent=75 +{% else %} +# 10-:-XX:G1ReservePercent=25 +# 10-:-XX:InitiatingHeapOccupancyPercent=30 +{% endif %} + +## DNS cache policy +# cache ttl in seconds for positive DNS lookups noting that this overrides the +# JDK security property networkaddress.cache.ttl; set to -1 to cache forever +-Des.networkaddress.cache.ttl=60 +# cache ttl in seconds for negative DNS lookups noting that this overrides the +# JDK security property networkaddress.cache.negative ttl; set to -1 to cache +# forever +-Des.networkaddress.cache.negative.ttl=10 + ## optimizations # pre-touch memory pages used by the JVM during initialization @@ -48,8 +70,8 @@ ## basic -# force the server VM --server +# explicitly set the stack size +-Xss1m # set to headless, just in case -Djava.awt.headless=true @@ -60,18 +82,23 @@ # use our provided JNA always versus the system one -Djna.nosys=true -# use old-style file permissions on JDK9 --Djdk.io.permissionsUseCanonicalPath=true +# turn off a JDK optimization that throws away stack traces for common +# exceptions because stack traces are important for debugging +-XX:-OmitStackTraceInFastThrow # flags to configure Netty -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 +{% if es_version is version('7.4.0', '>=') %} +-Dio.netty.allocator.numDirectArenas=0 +{% endif %} # log4j 2 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true --Dlog4j.skipJansi=true + +-Djava.io.tmpdir=${ES_TMPDIR} ## heap dumps @@ -79,30 +106,35 @@ # heap dumps are created in the working directory of the JVM -XX:+HeapDumpOnOutOfMemoryError -# specify an alternative path for heap dumps -# ensure the directory exists and has sufficient space -#-XX:HeapDumpPath=${heap.dump.path} +# specify an alternative path for heap dumps; ensure the directory exists and +# has sufficient space +-XX:HeapDumpPath=${heap.dump.path} -## GC logging +# specify an alternative path for JVM fatal error logs +-XX:ErrorFile={{ es_log_dir }}/hs_err_pid%p.log -#-XX:+PrintGCDetails -#-XX:+PrintGCTimeStamps -#-XX:+PrintGCDateStamps -#-XX:+PrintClassHistogram -#-XX:+PrintTenuringDistribution -#-XX:+PrintGCApplicationStoppedTime +## JDK 8 GC logging -# log GC status to a file with time stamps -# ensure the directory exists -#-Xloggc:${loggc} +8:-XX:+PrintGCDetails +8:-XX:+PrintGCDateStamps +8:-XX:+PrintTenuringDistribution +8:-XX:+PrintGCApplicationStoppedTime +8:-Xloggc:{{ es_log_dir }}/gc.log +8:-XX:+UseGCLogFileRotation +8:-XX:NumberOfGCLogFiles=32 +8:-XX:GCLogFileSize=64m +# JDK 9+ GC logging +9-:-Xlog:gc*,gc+age=trace,safepoint:file={{ es_log_dir }}/gc.log:utctime,pid,tags:filecount=32,filesize=64m +# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise +# time/date parsing will break in an incompatible way for some date patterns and locals +9-:-Djava.locale.providers=COMPAT + +{% if es_major_version == "6.x" %} +# temporary workaround for C2 bug with JDK 10 on hardware with AVX-512 +10-:-XX:UseAVX=2 +{% endif %} -# By default, the GC log file will not rotate. -# By uncommenting the lines below, the GC log file -# will be rotated every 128MB at most 32 times. -#-XX:+UseGCLogFileRotation -#-XX:NumberOfGCLogFiles=32 -#-XX:GCLogFileSize=128M {% if es_jvm_custom_parameters !='' %} {% for item in es_jvm_custom_parameters %} {{ item }}