From 15b7461bc7968bcfd8dfc516cf91c3548195e4a3 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Mon, 19 Jul 2021 20:04:11 +0200 Subject: [PATCH] removed Xms java memory startup parameter We will use the default value for now on. This is much better for resource economy and fits better into a container/docker/kubernetes strategy. Furthermore, a small memory footprint is essential for the usage on small devices like RaspberryPi. --- .travis.yml | 4 ++-- addon/yacy-svn-4.spec | 3 --- addon/yacyInit.m4 | 2 +- addon/yacyInit.sh | 6 ++--- build.xml | 1 - defaults/yacy.init | 5 +--- htroot/PerformanceQueues_p.java | 42 +++++++++++++++------------------ installYaCyWindowsService.bat | 1 - startYACY.bat | 3 +-- startYACY.sh | 10 ++++---- startYACY_debug.bat | 3 +-- 11 files changed, 31 insertions(+), 49 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1065bb36..20f87877a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,10 @@ before_install: - sudo apt-get install -y ghostscript dpkg-dev debhelper m4 fakeroot install: -- cd libbuild && MAVEN_OPTS="-Xmx6g -Xms2g" mvn clean install && cd .. +- cd libbuild && MAVEN_OPTS="-Xmx2g" mvn clean install && cd .. script: -- MAVEN_OPTS="-Xmx6g -Xms2g" mvn clean install +- MAVEN_OPTS="-Xmx2g" mvn clean install # test build instructions - ant - ant dist diff --git a/addon/yacy-svn-4.spec b/addon/yacy-svn-4.spec index ef633707c..717e32045 100644 --- a/addon/yacy-svn-4.spec +++ b/addon/yacy-svn-4.spec @@ -174,8 +174,6 @@ fi if [ -f \$DATA_HOME/SETTINGS/yacy.conf ]; then i=\`grep javastart_Xmx \$DATA_HOME/SETTINGS/yacy.conf\`; JAVA_MAX="-\${i#javastart_Xmx=}"; - i=\`grep javastart_Xms \$DATA_HOME/SETTINGS/yacy.conf\`; - JAVA_MIN="-\${i#javastart_Xms=}"; fi CLASSPATH="\$YACY_HOME/classes:." @@ -194,7 +192,6 @@ fi WTF=\$1; shift if [ "\$1" == "--max" ]; then JAVA_MAX="-Xmx\$2"; shift; shift; fi -if [ "\$1" == "--min" ]; then JAVA_MIN="-Xms\$2"; shift; shift; fi if [ "\$1" == "--nice" ]; then NICE="nice -n \$2"; shift; shift; fi if [ "\$1" == "--debug" ]; then DEBUG="-d"; shift; fi shift diff --git a/addon/yacyInit.m4 b/addon/yacyInit.m4 index b165f36ea..5a114ea97 100644 --- a/addon/yacyInit.m4 +++ b/addon/yacyInit.m4 @@ -110,7 +110,7 @@ then fi else - JAVA_ARGS="-Xmx120m -Xms120m $JAVA_ARGS" + JAVA_ARGS="-Xmx120m $JAVA_ARGS" fi # generating the proper classpath diff --git a/addon/yacyInit.sh b/addon/yacyInit.sh index 2ec6fb548..18100bc32 100755 --- a/addon/yacyInit.sh +++ b/addon/yacyInit.sh @@ -39,10 +39,8 @@ JAVA_ARGS="-Djava.awt.headless=true" if [ -f DATA/SETTINGS/yacy.conf ] then # startup memory - for i in Xmx Xms; do - j="`grep javastart_$i DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//'`"; - if [ -n $j ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi; - done + j="`grep javastart_Xmx DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//'`"; + if [ -n $j ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi; # Priority j="`grep javastart_priority DATA/SETTINGS/yacy.conf | sed 's/^[^=]*=//'`"; diff --git a/build.xml b/build.xml index f4309acaf..68cd16ef8 100644 --- a/build.xml +++ b/build.xml @@ -677,7 +677,6 @@ - diff --git a/defaults/yacy.init b/defaults/yacy.init index 40e56793f..d35d6de8c 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -760,11 +760,8 @@ cleanup.failedSearchURLtimeout = 86400000 # is valid in unix/shell and windows environments but # not for first startup of YaCy -# -Xmx and -Xms maximum/init Java heap size -# if a high performance for large search indexes is wanted, then setting the values to equal number is recommended -# if YaCy shall be nice in not-only-yacy environments, then the Xms value may be lower +# -Xmx maximum/init Java heap size javastart_Xmx=Xmx600m -javastart_Xms=Xms90m # YaCy is able to use RAM copies of database tables. This needs a lot of RAM. # To switch on copying of file tables int RAM, there must be enough memory diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java index 0771c5f15..b728216a2 100644 --- a/htroot/PerformanceQueues_p.java +++ b/htroot/PerformanceQueues_p.java @@ -55,17 +55,17 @@ public class PerformanceQueues_p { final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); File defaultSettingsFile = new File(sb.getAppPath(), "defaults/yacy.init"); - + /* Acquire a transaction token for the next POST form submission */ prop.put(TransactionManager.TRANSACTION_TOKEN_PARAM, TransactionManager.getTransactionToken(header)); // get segment - Segment indexSegment = sb.index; + final Segment indexSegment = sb.index; if(post != null) { /* Check the transaction is valid : validation apply then for every uses of this post parameter */ TransactionManager.checkPostTransaction(header, post); - + if(post.containsKey("resetObserver")) { /* The the reset state button is pushed, we only perform this action and do not save other form field values at the same time */ MemoryControl.resetProperState(); @@ -81,11 +81,9 @@ public class PerformanceQueues_p { if (post.containsKey("Xmx")) { int xmx = post.getInt("Xmx", 600); // default maximum heap size if (OS.isWin32) xmx = Math.min(2000, xmx); - int xms = xmx; //Math.min(xmx, Math.max(90, xmx / 10)); sb.setConfig("javastart_Xmx", "Xmx" + xmx + "m"); - sb.setConfig("javastart_Xms", "Xms" + xms + "m"); prop.put("setStartupCommit", "1"); - + /* Acquire a transaction token for the restart operation */ prop.put("setStartupCommit_" + TransactionManager.TRANSACTION_TOKEN_PARAM, TransactionManager.getTransactionToken(header, "/Steering.html")); } @@ -94,8 +92,8 @@ public class PerformanceQueues_p { } if(post.containsKey("diskFreeHardlimit")) { sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT, post.getLong("diskFreeHardlimit", SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT_DEFAULT)); - - /* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters, + + /* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters, * so we take only in account when the relate diskFreeHardlimit is set */ sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_AUTOREGULATE, post.getBoolean("diskFreeAutoregulate")); @@ -107,8 +105,8 @@ public class PerformanceQueues_p { if (post.containsKey("diskUsedHardlimit")) { sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_MAX_OVERSHOT, post.getLong("diskUsedHardlimit", SwitchboardConstants.RESOURCE_DISK_USED_MAX_OVERSHOT_DEFAULT)); - - /* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters, + + /* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters, * so we take only in account when the related diskFreeHardlimit is set */ sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_AUTOREGULATE, post.getBoolean("diskUsedAutoregulate")); @@ -155,7 +153,7 @@ public class PerformanceQueues_p { sb.setConfig("performanceSpeed", post.getInt("profileSpeed", 100)); } - IndexCell rwi = indexSegment.termIndex(); + final IndexCell rwi = indexSegment.termIndex(); while (threads.hasNext()) { threadName = threads.next(); thread = sb.getThread(threadName); @@ -257,7 +255,7 @@ public class PerformanceQueues_p { sb.setConfig(SwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount)); if (rwi != null) rwi.setBufferMaxWordCount(wordCacheMaxCount); } - + /* Setting remote searches max loads */ if (post != null) { if(post.containsKey("setRemoteSearchLoads")) { @@ -286,7 +284,7 @@ public class PerformanceQueues_p { // storing the new values into configfile sb.setConfig(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX,maxBusy); - + /* * configuring the robots.txt loading pool */ @@ -311,7 +309,7 @@ public class PerformanceQueues_p { sb.setConfig("httpdMaxBusySessions",maxBusy); } - + if ((post != null) && (post.containsKey("connectionPoolConfig"))) { /* Configure the general outgoing HTTP connection pool */ @@ -356,7 +354,7 @@ public class PerformanceQueues_p { prop.put("pool_0_name","Crawler Pool"); prop.put("pool_0_maxActive", sb.getConfigLong(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 0)); prop.put("pool_0_numActive", sb.crawlQueues.activeWorkerEntries().size()); - + prop.put("pool_1_name","Robots.txt Pool"); prop.put("pool_1_maxActive", sb.getConfigInt(SwitchboardConstants.ROBOTS_TXT_THREADS_ACTIVE_MAX, SwitchboardConstants.ROBOTS_TXT_THREADS_ACTIVE_MAX_DEFAULT)); prop.put("pool_1_numActive", sb.crawlQueues.activeWorkerEntries().size()); @@ -366,7 +364,7 @@ public class PerformanceQueues_p { prop.put("pool_2_numActive", ConnectionInfo.getServerCount()); prop.put("pool", "3"); - + /* Connection pools settings */ prop.put(SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL, sb.getConfigInt(SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL, @@ -379,23 +377,21 @@ public class PerformanceQueues_p { prop.put("pool.general.leased", stats.getLeased()); prop.put("pool.general.available", stats.getAvailable()); prop.put("pool.general.pending", stats.getPending()); - + stats = RemoteInstance.CONNECTION_MANAGER.getTotalStats(); prop.put("pool.remoteSolr.leased", stats.getLeased()); prop.put("pool.remoteSolr.available", stats.getAvailable()); prop.put("pool.remoteSolr.pending", stats.getPending()); - + /* Remote searches max loads settings */ prop.put("remoteSearchRWIMaxLoad", sb.getConfigFloat(SwitchboardConstants.REMOTESEARCH_MAXLOAD_RWI, SwitchboardConstants.REMOTESEARCH_MAXLOAD_RWI_DEFAULT)); prop.put("remoteSearchSolrMaxLoad", sb.getConfigFloat(SwitchboardConstants.REMOTESEARCH_MAXLOAD_SOLR, SwitchboardConstants.REMOTESEARCH_MAXLOAD_SOLR_DEFAULT)); - // parse initialization memory settings - final String Xmx = sb.getConfig("javastart_Xmx", "Xmx600m").substring(3); - prop.put("Xmx", Xmx.substring(0, Xmx.length() - 1)); - final String Xms = sb.getConfig("javastart_Xms", "Xms600m").substring(3); - prop.put("Xms", Xms.substring(0, Xms.length() - 1)); + // parse initialization memory settings + final String Xmx = sb.getConfig("javastart_Xmx", "Xmx600m").substring(3); + prop.put("Xmx", Xmx.substring(0, Xmx.length() - 1)); final long diskFree = sb.getConfigLong(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_STEADYSTATE, 3000L); final long diskFreeHardlimit = sb.getConfigLong(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT, 1000L); diff --git a/installYaCyWindowsService.bat b/installYaCyWindowsService.bat index a9248510d..1ede085ea 100644 --- a/installYaCyWindowsService.bat +++ b/installYaCyWindowsService.bat @@ -14,7 +14,6 @@ Rem This target is used to read java runtime parameters out of the yacy config f :GETSTARTOPTS REM for /F "tokens=1,2 delims==" %%i in (DATA\SETTINGS\yacy.conf) do ( REM if "%%i"=="javastart_Xmx" set jmx=%%j -REM if "%%i"=="javastart_Xms" set jms=%%j REM ) Rem choose service runner executable according to processor architecture diff --git a/startYACY.bat b/startYACY.bat index 0c72bd11d..c31a4b266 100644 --- a/startYACY.bat +++ b/startYACY.bat @@ -11,7 +11,7 @@ Set CLASSPATH=lib\yacycore.jar REM Please change the "javastart" settings in the web-interface "Basic Configuration" -> "Advanced" set jmx= set jms= -set javacmd=-Xmx600m -Xms180m +set javacmd=-Xmx600m set priolvl=10 set priority=/BELOWNORMAL if exist DATA\SETTINGS\httpProxy.conf GoTo :RENAMEINDEX @@ -56,7 +56,6 @@ Rem This target is used to read java runtime parameters out of the yacy config f :GETSTARTOPTS for /F "tokens=1,2 delims==" %%i in (DATA\SETTINGS\yacy.conf) do ( if "%%i"=="javastart_Xmx" set jmx=%%j - if "%%i"=="javastart_Xms" set jms=%%j if "%%i"=="javastart_priority" set priolvl=%%j ) if defined jmx set javacmd=-%jmx% diff --git a/startYACY.sh b/startYACY.sh index 203eaeecf..0280b01ee 100755 --- a/startYACY.sh +++ b/startYACY.sh @@ -192,11 +192,9 @@ fi if [ -f $CONFIGFILE ] then # startup memory - for i in Xmx Xms; do - j="`grep javastart_$i $CONFIGFILE | sed 's/^[^=]*=//'`"; - if [ -n "$j" ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi; - done - + j="`grep javastart_Xmx $CONFIGFILE | sed 's/^[^=]*=//'`"; + if [ -n "$j" ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi; + # Priority j="`grep javastart_priority $CONFIGFILE | sed 's/^[^=]*=//'`"; @@ -210,7 +208,7 @@ then # JAVA_ARGS="-$i $JAVA_ARGS"; # done else - JAVA_ARGS="-Xmx600m -Xms180m $JAVA_ARGS"; + JAVA_ARGS="-Xmx600m $JAVA_ARGS"; PORT="8090" fi diff --git a/startYACY_debug.bat b/startYACY_debug.bat index a5eb9a3ee..6dc5b6d55 100644 --- a/startYACY_debug.bat +++ b/startYACY_debug.bat @@ -9,7 +9,7 @@ Set CLASSPATH=lib/yacycore.jar REM Please change the "javastart" settings in the web-interface "Basic Configuration" -> "Advanced" set jmx= set jms= -set javacmd=-Xmx600m -Xms180m +set javacmd=-Xmx600m set priolvl=10 set priority=/BELOWNORMAL set port=8090 @@ -60,7 +60,6 @@ Rem This target is used to read java runtime parameters out of the yacy config f :GETSTARTOPTS for /F "tokens=1,2 delims==" %%i in (DATA\SETTINGS\yacy.conf) do ( if "%%i"=="javastart_Xmx" set jmx=%%j - if "%%i"=="javastart_Xms" set jms=%%j if "%%i"=="port" set port=%%j if "%%i"=="javastart_priority" set priolvl=%%j )