From 168d688fc96b19c0e87cfadbecb9e9bebd4db147 Mon Sep 17 00:00:00 2001
From: dev <dev@robertfoss.se>
Date: Thu, 2 Apr 2015 16:05:43 +0000
Subject: [PATCH] Disable JVM stats being written to file, to prevent long (up
 to ~400ms) pauses.

    - Blog post: http://www.evanjones.ca/jvm-mmap-pause.html
    - This change prevents tools that use the stats-file (/tmp/hsperfdata) from working (like jstat)
---
 .../resources/portable/configs/wrapper.config  | 15 ++++++++++-----
 installer/resources/small/wrapper.config       |  4 ++++
 installer/resources/wrapper.config             | 18 +++++++++++-------
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/installer/resources/portable/configs/wrapper.config b/installer/resources/portable/configs/wrapper.config
index db04ae951d..812768c7c6 100644
--- a/installer/resources/portable/configs/wrapper.config
+++ b/installer/resources/portable/configs/wrapper.config
@@ -18,14 +18,19 @@ wrapper.java.additional.3=-Dorg.mortbay.util.FileResource.checkAliases=false
 wrapper.java.additional.4=-Dorg.mortbay.xml.XmlParser.NotValidating=true
 wrapper.java.additional.5=-Di2p.dir.base=.
 wrapper.java.additional.5.stripquotes=TRUE
+
+# Prevent the JVM from exporting stats (and thereby causing hundreds of
+# ms long pauses during GC)
+wrapper.java.additional.6=-XX:+PerfDisableSharedMem
+
 # PORTABLE installation:
 # uncomment the following
-wrapper.java.additional.6=-Di2p.dir.pid=logs
-wrapper.java.additional.6.stripquotes=TRUE
-wrapper.java.additional.7=-Di2p.dir.temp=tmp
+wrapper.java.additional.7=-Di2p.dir.pid=logs
 wrapper.java.additional.7.stripquotes=TRUE
-wrapper.java.additional.8=-Di2p.dir.config=.
+wrapper.java.additional.8=-Di2p.dir.temp=tmp
 wrapper.java.additional.8.stripquotes=TRUE
+wrapper.java.additional.9=-Di2p.dir.config=.
+wrapper.java.additional.9.stripquotes=TRUE
 
 # Uncomment this for better performance.
 # If it doesn't work, server mode is not available in your JVM.
@@ -139,4 +144,4 @@ wrapper.pidfile=logs/i2p.pid
 #********************************************************************
 # Wrapper NT Service Properties
 #********************************************************************
-# Not useful for portable version - BOOM
\ No newline at end of file
+# Not useful for portable version - BOOM
diff --git a/installer/resources/small/wrapper.config b/installer/resources/small/wrapper.config
index 359ef949d2..b60660ef09 100644
--- a/installer/resources/small/wrapper.config
+++ b/installer/resources/small/wrapper.config
@@ -59,6 +59,10 @@ wrapper.java.additional.2=-Dorg.mortbay.http.Version.paranoid=true
 wrapper.java.additional.3=-Dorg.mortbay.util.FileResource.checkAliases=false
 wrapper.java.additional.4=-Dorg.mortbay.xml.XmlParser.NotValidating=true
 
+# Prevent the JVM from exporting stats (and thereby causing hundreds of
+# ms long pauses during GC)
+wrapper.java.additional.5=-XX:+PerfDisableSharedMem
+
 # Initial Java Heap Size (in MB)
 #wrapper.java.initmemory=4
 
diff --git a/installer/resources/wrapper.config b/installer/resources/wrapper.config
index b17b3a83dd..390ab8dbde 100644
--- a/installer/resources/wrapper.config
+++ b/installer/resources/wrapper.config
@@ -79,29 +79,33 @@ wrapper.java.additional.3=-Dorg.mortbay.xml.XmlParser.NotValidating=true
 wrapper.java.additional.4=-Di2p.dir.base="$INSTALL_PATH"
 wrapper.java.additional.4.stripquotes=TRUE
 
+# Prevent the JVM from exporting stats (and thereby causing hundreds of
+# ms long pauses during GC)
+wrapper.java.additional.5=-XX:+PerfDisableSharedMem
+
 # On some IPv6 enabled systems, I2P and other network-enabled java applications
 # may fail to start. For examples see
 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560044.
 # Two things that may help if you experience this issue
 # 1) "echo 0 > /proc/sys/net/ipv6/bindv6only" as root; or
 # 2) uncomment the next two lines:
-#wrapper.java.additional.5=-Djava.net.preferIPv4Stack=true
-#wrapper.java.additional.6=-Djava.net.preferIPv6Addresses=false
+#wrapper.java.additional.6=-Djava.net.preferIPv4Stack=true
+#wrapper.java.additional.7=-Djava.net.preferIPv6Addresses=false
 
 # Jetty says this is a security risk
 # Uncommenting this won't help as the router forces it to true
 # If you really need this, you have to set it in jetty.xml
 # somehow - not sure exactly but here's a clue:
 # org.mortbay.util.FileResource.setCheckAliases(false)
-# wrapper.java.additional.7=-Dorg.mortbay.util.FileResource.checkAliases=false
+# wrapper.java.additional.8=-Dorg.mortbay.util.FileResource.checkAliases=false
 # PORTABLE installation:
 # uncomment the following
-#wrapper.java.additional.7=-Di2p.dir.pid="$INSTALL_PATH"
-#wrapper.java.additional.7.stripquotes=TRUE
-#wrapper.java.additional.8=-Di2p.dir.temp="$INSTALL_PATH"
+#wrapper.java.additional.8=-Di2p.dir.pid="$INSTALL_PATH"
 #wrapper.java.additional.8.stripquotes=TRUE
-#wrapper.java.additional.9=-Di2p.dir.config="$INSTALL_PATH"
+#wrapper.java.additional.9=-Di2p.dir.temp="$INSTALL_PATH"
 #wrapper.java.additional.9.stripquotes=TRUE
+#wrapper.java.additional.10=-Di2p.dir.config="$INSTALL_PATH"
+#wrapper.java.additional.10.stripquotes=TRUE
 #
 # Uncomment this for better performance.
 # If it doesn't work, server mode is not available in your JVM.
-- 
GitLab