Skip to content

Commit 22e7165

Browse files
committed
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.
1 parent 0bbb84c commit 22e7165

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

distribution/src/main/resources/bin/elasticsearch.in.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof
8585
REM Disables explicit GC
8686
set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC
8787

88+
REM Enable pre-touching of memory pages used by the JVM during hotspot
89+
REM initialization
90+
set JAVA_OPTS=%JAVA_OPTS% -XX:+AlwaysPreTouch
91+
8892
REM Ensure UTF-8 encoding by default (e.g. filenames)
8993
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
9094

distribution/src/main/resources/bin/elasticsearch.in.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
8181
# Disables explicit GC
8282
JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
8383

84+
# Enable pre-touching of memory pages used by the JVM during hotspot
85+
# initialization
86+
JAVA_OPTS="$JAVA_OPTS -XX:+AlwaysPreTouch"
87+
8488
# Ensure UTF-8 encoding by default (e.g. filenames)
8589
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
8690

docs/reference/migration/migrate_5_0.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,15 @@ changed to now route standard output to the journal and standard error
808808
to inherit this setting (these are the defaults for systemd). These
809809
settings can be modified by editing the elasticsearch.service file.
810810

811+
==== Longer startup times
812+
813+
In Elasticsearch 5.0.0 the `-XX:+AlwaysPreTouch` flag has been added to the JVM
814+
startup options. This option touches all memory pages used by the JVM heap
815+
during initialization of the HotSpot VM to reduce the chance of having to commit
816+
a memory page during GC time. This will increase the startup time of
817+
Elasticsearch as well as increasing the initial resident memory usage of the
818+
Java process.
819+
811820
[[breaking_50_scripting]]
812821
=== Scripting
813822

0 commit comments

Comments
 (0)