Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
configurable max-load values for YaCy-Threads: try lower values on smal systems like a Pi
sixcooler40a4030b553b
diff --git a/defaults/yacy.init b/defaults/yacy.initindex f24c158ee..615c69f14 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -598,33 +598,42 @@ collection=user20_dhtdistribution_idlesleep=3000020_dhtdistribution_busysleep=1500020_dhtdistribution_memprereq=12582912+20_dhtdistribution_loadprereq=2.030_peerping_idlesleep=3000030_peerping_busysleep=3000030_peerping_memprereq=2097152+30_peerping_loadprereq=2.040_peerseedcycle_idlesleep=180000040_peerseedcycle_busysleep=120000040_peerseedcycle_memprereq=4194304+40_peerseedcycle_loadprereq=2.050_localcrawl_idlesleep=200050_localcrawl_busysleep=1050_localcrawl_memprereq=12582912+50_localcrawl_loadprereq=2.050_localcrawl_isPaused=false60_remotecrawlloader_idlesleep=400060_remotecrawlloader_busysleep=80060_remotecrawlloader_memprereq=12582912+60_remotecrawlloader_loadprereq=2.060_remotecrawlloader_isPaused=false62_remotetriggeredcrawl_idlesleep=200062_remotetriggeredcrawl_busysleep=20062_remotetriggeredcrawl_memprereq=12582912+62_remotetriggeredcrawl_loadprereq=2.062_remotetriggeredcrawl_isPaused=false70_surrogates_idlesleep=1000070_surrogates_busysleep=070_surrogates_memprereq=12582912+70_surrogates_loadprereq=2.080_searchresult_idlesleep=1000080_searchresult_busysleep=20080_searchresult_memprereq=0+80_searchresult_loadprereq=2.090_cleanup_idlesleep=30000090_cleanup_busysleep=30000090_cleanup_memprereq=0+90_cleanup_loadprereq=3.0# additional attributes:# performanceIO is a percent-value. a value of 10 means, that 10% of the busysleep timediff --git a/htroot/PerformanceQueues_p.html b/htroot/PerformanceQueues_p.htmlindex afdbeb5d1..6cf5ce64d 100644--- a/htroot/PerformanceQueues_p.html+++ b/htroot/PerformanceQueues_p.html@@ -29,6 +29,7 @@<td>Delay between<br />idle loops</td><td>Delay between<br />busy loops</td><td>Minimum of<br />Required Memory</td>+ <td>Maximum of<br />System-Load</td><td>Full Description</td></tr>#{table}#@@ -51,6 +52,7 @@<td align="right"><input name="#[threadname]#_idlesleep" size="7" maxlength="7" value="#[idlesleep]#" #(disabled)#:: disabled="disabled"#(/disabled)# /> milliseconds</td><td align="right"><input name="#[threadname]#_busysleep" size="7" maxlength="7" value="#[busysleep]#" #(disabled)#:: disabled="disabled"#(/disabled)# /> milliseconds</td><td align="right"><input name="#[threadname]#_memprereq" size="7" maxlength="10" value="#[memprereq]#" #(disabled)#:: disabled="disabled"#(/disabled)# /> kbytes</td>+ <td align="right"><input name="#[threadname]#_loadprereq" size="7" maxlength="7" value="#[loadprereq]#" #(disabled)#:: disabled="disabled"#(/disabled)# /> load</td><td align="left">#[longdescr]##(recommendation)#::<br/>recommended: #[value]# kbytes#(/recommendation)#</td></tr>#{/table}#diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.javaindex 58d555029..9de319a04 100644--- a/htroot/PerformanceQueues_p.java+++ b/htroot/PerformanceQueues_p.java@@ -119,6 +119,7 @@ public class PerformanceQueues_p {// set templates for latest news from the threadslong blocktime, sleeptime, exectime;long idlesleep, busysleep, memuse, memprereq;+ double loadprereq;int queuesize;threads = sb.threadNames();int c = 0;@@ -177,18 +178,21 @@ public class PerformanceQueues_p {idlesleep = sb.getConfigLong(threadName + "_idlesleep" , 1000);busysleep = sb.getConfigLong(threadName + "_busysleep", 100);memprereq = sb.getConfigLong(threadName + "_memprereq", 0);+ loadprereq = sb.getConfigFloat(threadName + "_loadprereq", 9);if (setDelay && post != null) {// load with new valuesidlesleep = post.getLong(threadName + "_idlesleep", idlesleep);busysleep = post.getLong(threadName + "_busysleep", busysleep);memprereq = post.getLong(threadName + "_memprereq", memprereq) * 1024l;if (memprereq == 0) memprereq = sb.getConfigLong(threadName + "_memprereq", 0);+ loadprereq = post.getDouble(threadName + "_loadprereq", loadprereq);+ if (loadprereq == 0) loadprereq = sb.getConfigFloat(threadName + "_loadprereq", 9);// check values to prevent short-cut loopsif (idlesleep < 1000) idlesleep = 1000;- if (threadName.equals("10_httpd")) { idlesleep = 0; busysleep = 0; memprereq = 0; }+ if (threadName.equals("10_httpd")) { idlesleep = 0; busysleep = 0; memprereq = 0; loadprereq = 9; }- sb.setThreadPerformance(threadName, idlesleep, busysleep, memprereq);+ sb.setThreadPerformance(threadName, idlesleep, busysleep, memprereq, loadprereq);idlesleep = sb.getConfigLong(threadName + "_idlesleep", idlesleep);busysleep = sb.getConfigLong(threadName + "_busysleep", busysleep);}@@ -205,14 +209,15 @@ public class PerformanceQueues_p {// check values to prevent short-cut loopsif (idlesleep < 1000) idlesleep = 1000;- if (threadName.equals("10_httpd")) { idlesleep = 0; busysleep = 0; memprereq = 0; }+ if (threadName.equals("10_httpd")) { idlesleep = 0; busysleep = 0; memprereq = 0; loadprereq = 9; }//if (threadName.equals(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) && (busysleep < 50)) busysleep = 50;- sb.setThreadPerformance(threadName, idlesleep, busysleep, memprereq);+ sb.setThreadPerformance(threadName, idlesleep, busysleep, memprereq, loadprereq);}}prop.put("table_" + c + "_idlesleep", idlesleep);prop.put("table_" + c + "_busysleep", busysleep);prop.put("table_" + c + "_memprereq", memprereq / 1024);+ prop.put("table_" + c + "_loadprereq", loadprereq);// disallow setting of memprereq for indexer to prevent db from throwing OOMs// prop.put("table_" + c + "_disabled", /*(threadName.endsWith("_indexing")) ? 1 :*/ "0");prop.put("table_" + c + "_disabled", threadName.equals("10_httpd") ? "1" : "0" ); // httpd hardcoded defaultsdiff --git a/htroot/PerformanceQueues_p.xml b/htroot/PerformanceQueues_p.xmlindex e7fc14d95..bef61d6d6 100644--- a/htroot/PerformanceQueues_p.xml+++ b/htroot/PerformanceQueues_p.xml@@ -20,6 +20,7 @@<delayIdleLoop>#[idlesleep]#</delayIdleLoop><delayBusyLoop>#[busysleep]#</delayBusyLoop><minMemory>#[memprereq]#</minMemory>+ <minMemory>#[loadprereq]#</minMemory><description><![CDATA[#[longdescr]##(recommendation)#::<br/>recommended: #[value]##(/recommendation)#]]></description></Task>#{/table}#</Tasks>diff --git a/source/net/yacy/kelondro/util/MemoryControl.java b/source/net/yacy/kelondro/util/MemoryControl.javaindex f3c9c0781..09b2c18dc 100644--- a/source/net/yacy/kelondro/util/MemoryControl.java+++ b/source/net/yacy/kelondro/util/MemoryControl.java@@ -25,6 +25,8 @@package net.yacy.kelondro.util;+import java.lang.management.ManagementFactory;+/*** Use this to get information about memory usage or try to free some memory*/@@ -174,6 +176,14 @@ public class MemoryControl {public static void setProperMbyte(final long mbyte) {getStrategy().setProperMbyte(mbyte);}++ /**+ * get the system load within the last minute+ * @return the system load or a negative number if the load is not available+ */+ public static double load() {+ return ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();+ }/*** maindiff --git a/source/net/yacy/kelondro/workflow/AbstractBusyThread.java b/source/net/yacy/kelondro/workflow/AbstractBusyThread.javaindex 298afa0ad..4b1fe7b01 100644--- a/source/net/yacy/kelondro/workflow/AbstractBusyThread.java+++ b/source/net/yacy/kelondro/workflow/AbstractBusyThread.java@@ -37,6 +37,7 @@ public abstract class AbstractBusyThread extends AbstractThread implements BusyTprivate long startup = 0, intermission = 0, idlePause = 0, busyPause = 0;private long idletime = 0, memprereq = 0;private long idleCycles = 0, busyCycles = 0, outofmemoryCycles = 0;+ private double loadprereq = 9;private boolean intermissionObedient = true;private final Object syncObject = new Object();@@ -84,6 +85,11 @@ public abstract class AbstractBusyThread extends AbstractThread implements BusyTmemprereq = freeBytes;}+ public void setLoadPreReqisite(final double load) {+ // sets minimum required amount of memory for the job execution+ loadprereq = load;+ }+public void setObeyIntermission(final boolean obey) {// defines if the thread should obey the intermission commandintermissionObedient = obey;@@ -158,6 +164,11 @@ public abstract class AbstractBusyThread extends AbstractThread implements BusyTratz(this.idlePause);idletime += System.currentTimeMillis() - timestamp;//} else if ((memnow = serverMemory.available()) > memprereq) try {+ } else if (MemoryControl.load() > loadprereq) {+ logSystem("Thread '" + this.getName() + "' runs high load cycle. current: " + MemoryControl.load() + " max.: " + loadprereq);+ timestamp = System.currentTimeMillis();+ ratz(this.idlePause);+ idletime += System.currentTimeMillis() - timestamp;} else if (MemoryControl.request(memprereq, false)) try {// do jobtimestamp = System.currentTimeMillis();diff --git a/source/net/yacy/kelondro/workflow/BusyThread.java b/source/net/yacy/kelondro/workflow/BusyThread.javaindex 1b559c947..200f7bd79 100644--- a/source/net/yacy/kelondro/workflow/BusyThread.java+++ b/source/net/yacy/kelondro/workflow/BusyThread.java@@ -64,6 +64,12 @@ public interface BusyThread extends WorkflowThread {* @param freeBytes*/public void setMemPreReqisite(long freeBytes);++ /**+ * sets maximimum load for the job execution+ * @param load+ */+ public void setLoadPreReqisite(final double load);/*** defines if the thread should obey the intermission commanddiff --git a/source/net/yacy/kelondro/workflow/InstantBusyThread.java b/source/net/yacy/kelondro/workflow/InstantBusyThread.javaindex e8c3df3c5..846f5e669 100644--- a/source/net/yacy/kelondro/workflow/InstantBusyThread.java+++ b/source/net/yacy/kelondro/workflow/InstantBusyThread.java@@ -165,6 +165,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTthread.setIdleSleep(-1);thread.setBusySleep(-1);thread.setMemPreReqisite(0);+ thread.setLoadPreReqisite(3);thread.start();return thread;}diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex e05ca0fe0..aea45e0ca 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -1094,7 +1094,8 @@ public final class Switchboard extends serverSwitch {60000,Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_IDLESLEEP, "5000")),Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_BUSYSLEEP, "0")),- Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_MEMPREREQ, "1000000")));+ Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_MEMPREREQ, "1000000")),+ Double.parseDouble(getConfig(SwitchboardConstants.INDEX_DIST_LOADPREREQ, "9.0")));// content control: initialize list sync threaddeployThread(diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.javaindex cc1630879..ff6fb3908 100644--- a/source/net/yacy/search/SwitchboardConstants.java+++ b/source/net/yacy/search/SwitchboardConstants.java@@ -62,6 +62,7 @@ public final class SwitchboardConstants {public static final String INDEX_DIST_METHOD_JOBCOUNT = null;public static final String INDEX_DIST_METHOD_FREEMEM = null;public static final String INDEX_DIST_MEMPREREQ = "20_dhtdistribution_memprereq";+ public static final String INDEX_DIST_LOADPREREQ = "20_dhtdistribution_loadprereq";public static final String INDEX_DIST_IDLESLEEP = "20_dhtdistribution_idlesleep";public static final String INDEX_DIST_BUSYSLEEP = "20_dhtdistribution_busysleep";// 30_peerping@@ -132,6 +133,7 @@ public final class SwitchboardConstants {*/public static final String SURROGATES = "70_surrogates";public static final String SURROGATES_MEMPREREQ = "70_surrogates_memprereq";+ public static final String SURROGATES_LOADPREREQ = "70_surrogates_loadprereq";public static final String SURROGATES_IDLESLEEP = "70_surrogates_idlesleep";public static final String SURROGATES_BUSYSLEEP = "70_surrogates_busysleep";public static final String SURROGATES_METHOD_START = "surrogateProcess";@@ -144,6 +146,7 @@ public final class SwitchboardConstants {*/public static final String SEARCHRESULT = "80_searchresult";public static final String SEARCHRESULT_MEMPREREQ = "80_searchresult_memprereq";+ public static final String SEARCHRESULT_LOADPREREQ = "80_searchresult_loadprereq";public static final String SEARCHRESULT_IDLESLEEP = "80_searchresult_idlesleep";public static final String SEARCHRESULT_BUSYSLEEP = "80_searchresult_busysleep";public static final String SEARCHRESULT_METHOD_START = "searchresultProcess";diff --git a/source/net/yacy/server/serverSwitch.java b/source/net/yacy/server/serverSwitch.javaindex d682782e1..06c25db7d 100644--- a/source/net/yacy/server/serverSwitch.java+++ b/source/net/yacy/server/serverSwitch.java@@ -344,7 +344,8 @@ public class serverSwitchstartupDelay,Long.parseLong(getConfig(threadName + "_idlesleep", "100")),Long.parseLong(getConfig(threadName + "_busysleep", "1000")),- Long.parseLong(getConfig(threadName + "_memprereq", "1000000")));+ Long.parseLong(getConfig(threadName + "_memprereq", "1000000")),+ Double.parseDouble(getConfig(threadName + "_loadprereq", "9.0")));}public void deployThread(@@ -356,7 +357,8 @@ public class serverSwitchfinal long startupDelay,final long initialIdleSleep,final long initialBusySleep,- final long initialMemoryPreRequisite) {+ final long initialMemoryPreRequisite,+ final double initialLoadPreRequisite) {if ( newThread.isAlive() ) {throw new RuntimeException("undeployed threads must not live; they are started as part of the deployment");@@ -384,6 +386,13 @@ public class serverSwitchnewThread.setMemPreReqisite(initialMemoryPreRequisite);setConfig(threadName + "_memprereq", initialMemoryPreRequisite);}+ try {+ final double load = Double.parseDouble(getConfig(threadName + "_loadprereq", "novalue"));+ newThread.setLoadPreReqisite(load);+ } catch (final NumberFormatException e ) {+ newThread.setLoadPreReqisite(initialLoadPreRequisite);+ setConfig(threadName + "_loadprereq", (float)initialLoadPreRequisite);+ }newThread.setDescription(threadShortDescription, threadLongDescription, threadMonitorURL);this.workerThreads.put(threadName, newThread);// start the thread@@ -400,13 +409,16 @@ public class serverSwitchfinal String threadName,final long idleMillis,final long busyMillis,- final long memprereqBytes) {+ final long memprereqBytes,+ final double loadprereq) {final BusyThread thread = this.workerThreads.get(threadName);if ( thread != null ) {setConfig(threadName + "_idlesleep", thread.setIdleSleep(idleMillis));setConfig(threadName + "_busysleep", thread.setBusySleep(busyMillis));setConfig(threadName + "_memprereq", memprereqBytes);thread.setMemPreReqisite(memprereqBytes);+ setConfig(threadName + "_loadprereq", (float)loadprereq);+ thread.setLoadPreReqisite(loadprereq);}}