From 22e716551bb87b4b28da46b949b317c69f9b4a1b Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 3 Mar 2016 11:44:56 -0700 Subject: [PATCH] Add -XX+AlwaysPreTouch JVM flag Enables the touching of all memory pages used by the JVM heap spaces during initialization of the HotSpot VM, which commits all memory pages at initialization time. By default, pages are committed only as they are needed. --- distribution/src/main/resources/bin/elasticsearch.in.bat | 4 ++++ distribution/src/main/resources/bin/elasticsearch.in.sh | 4 ++++ docs/reference/migration/migrate_5_0.asciidoc | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/distribution/src/main/resources/bin/elasticsearch.in.bat b/distribution/src/main/resources/bin/elasticsearch.in.bat index 7138cf5f5ca..b909a464952 100644 --- a/distribution/src/main/resources/bin/elasticsearch.in.bat +++ b/distribution/src/main/resources/bin/elasticsearch.in.bat @@ -85,6 +85,10 @@ REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof REM Disables explicit GC set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC +REM Enable pre-touching of memory pages used by the JVM during hotspot +REM initialization +set JAVA_OPTS=%JAVA_OPTS% -XX:+AlwaysPreTouch + REM Ensure UTF-8 encoding by default (e.g. filenames) set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8 diff --git a/distribution/src/main/resources/bin/elasticsearch.in.sh b/distribution/src/main/resources/bin/elasticsearch.in.sh index f859a06ffab..69d2fc94112 100644 --- a/distribution/src/main/resources/bin/elasticsearch.in.sh +++ b/distribution/src/main/resources/bin/elasticsearch.in.sh @@ -81,6 +81,10 @@ JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" # Disables explicit GC JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC" +# Enable pre-touching of memory pages used by the JVM during hotspot +# initialization +JAVA_OPTS="$JAVA_OPTS -XX:+AlwaysPreTouch" + # Ensure UTF-8 encoding by default (e.g. filenames) JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" diff --git a/docs/reference/migration/migrate_5_0.asciidoc b/docs/reference/migration/migrate_5_0.asciidoc index 6fcf566fdcb..37c73698779 100644 --- a/docs/reference/migration/migrate_5_0.asciidoc +++ b/docs/reference/migration/migrate_5_0.asciidoc @@ -808,6 +808,15 @@ changed to now route standard output to the journal and standard error to inherit this setting (these are the defaults for systemd). These settings can be modified by editing the elasticsearch.service file. +==== Longer startup times + +In Elasticsearch 5.0.0 the `-XX:+AlwaysPreTouch` flag has been added to the JVM +startup options. This option touches all memory pages used by the JVM heap +during initialization of the HotSpot VM to reduce the chance of having to commit +a memory page during GC time. This will increase the startup time of +Elasticsearch as well as increasing the initial resident memory usage of the +Java process. + [[breaking_50_scripting]] === Scripting