Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
memory-logging
orbiter2c7b490e3040
diff --git a/htroot/PerformanceQueues_p.html b/htroot/PerformanceQueues_p.htmlindex 3de7f221f..fdbefd288 100644--- a/htroot/PerformanceQueues_p.html+++ b/htroot/PerformanceQueues_p.html@@ -26,6 +26,7 @@<td class="small">Short Mem<br>Cycles</td><td class="small">Sleep Time<br>per Cycle<br>(millis)</td><td class="small">Exec Time<br>per Busy-Cycle<br>(millis)</td>+<td class="small">Memoy Use<br>per Busy-Cycle<br>(kbytes)</td><td class="small">Delay between<br>idle loops</td><td class="small">Delay between<br>busy loops</td><td class="small">Minimum of<br>Required Memory</td>@@ -47,6 +48,7 @@<td class="small" align="right">#[memscycles]#</td><td class="small" align="right">#[sleeppercycle]#</td><td class="small" align="right">#[execpercycle]#</td>+<td class="small" align="right">#[memusepercycle]#</td><td class="small" align="right"><input name="#[threadname]#_idlesleep" type="text" align="right" size="7" maxlength="7" value="#[idlesleep]#"> milliseconds</td><td class="small" align="right"><input name="#[threadname]#_busysleep" type="text" align="right" size="7" maxlength="7" value="#[busysleep]#"> milliseconds</td><td class="small" align="right"><input name="#[threadname]#_memprereq" type="text" align="right" size="8" maxlength="8" value="#[memprereq]#"> bytes</td>diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.javaindex 695f26cb4..021ab893e 100644--- a/htroot/PerformanceQueues_p.java+++ b/htroot/PerformanceQueues_p.java@@ -85,7 +85,7 @@ public class PerformanceQueues_p {// set templates for latest news from the threadslong blocktime, sleeptime, exectime;- long idlesleep, busysleep, memprereq;+ long idlesleep, busysleep, memuse, memprereq;int queuesize;threads = switchboard.threadNames();int c = 0;@@ -104,6 +104,7 @@ public class PerformanceQueues_p {blocktime = thread.getBlockTime();sleeptime = thread.getSleepTime();exectime = thread.getExecTime();+ memuse = thread.getMemoryUse();idleCycles = thread.getIdleCycles();busyCycles = thread.getBusyCycles();memshortageCycles = thread.getOutOfMemoryCycles();@@ -119,6 +120,7 @@ public class PerformanceQueues_p {prop.put("table_" + c + "_memscycles", Long.toString(memshortageCycles));prop.put("table_" + c + "_sleeppercycle", ((idleCycles + busyCycles) == 0) ? "-" : Long.toString(sleeptime / (idleCycles + busyCycles)));prop.put("table_" + c + "_execpercycle", (busyCycles == 0) ? "-" : Long.toString(exectime / busyCycles));+ prop.put("table_" + c + "_memusepercycle", (busyCycles == 0) ? "-" : Long.toString(memuse / busyCycles / 1024));if ((post != null) && (post.containsKey("submitdelay"))) {// load with new valuesdiff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 9106db6f0..cf6c7d27d 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -436,7 +436,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements sergetConfig("allowDistributeIndexWhileCrawling","false").equals("true"));indexDistribution.setCounts(150, 1, 3, 10000);deployThread("20_dhtdistribution", "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,- new serverInstantThread(indexDistribution, "job", null), 12000);+ new serverInstantThread(indexDistribution, "job", null), 600000);// init migratiion from 0.37 -> 0.38classicCache = new plasmaWordIndexClassicCacheMigration(plasmaPath, wordIndex);diff --git a/source/de/anomic/server/serverAbstractThread.java b/source/de/anomic/server/serverAbstractThread.javaindex f90d2bad2..c7c670575 100644--- a/source/de/anomic/server/serverAbstractThread.java+++ b/source/de/anomic/server/serverAbstractThread.java@@ -57,7 +57,7 @@ public abstract class serverAbstractThread extends Thread implements serverThreaprivate long startup = 0, intermission = 0, idlePause = 0, busyPause = 0, blockPause = 0;private boolean running = true;private serverLog log = null;- private long idletime = 0, busytime = 0, memprereq = 0;+ private long idletime = 0, busytime = 0, memprereq = 0, memuse = 0;private String shortDescr = "", longDescr = "";private String monitorURL = null;private long threadBlockTimestamp = System.currentTimeMillis();@@ -158,6 +158,11 @@ public abstract class serverAbstractThread extends Thread implements serverThreareturn this.busytime;}+ public long getMemoryUse() {+ // returns the sum of all memory usage differences before and after one busy job+ return memuse;+ }+public final void setLog(serverLog log) {// defines a log where process states can be written tothis.log = log;@@ -227,6 +232,7 @@ public abstract class serverAbstractThread extends Thread implements serverThreaint outerloop;long innerpause;long timestamp;+ long memstamp0, memstamp1;boolean isBusy;Runtime rt = Runtime.getRuntime();@@ -240,16 +246,30 @@ public abstract class serverAbstractThread extends Thread implements serverThreaif (rt.freeMemory() > memprereq) try {// do jobtimestamp = System.currentTimeMillis();+ memstamp0 = serverMemory.used();isBusy = this.job();+ // do memory and busy/idle-count/time monitoring+ if (isBusy) {+ memstamp1 = serverMemory.used();+ if (memstamp1 >= memstamp0) {+ // no GC in between. this is not shure but most probable+ memuse += memstamp1 - memstamp0;+ } else {+ // GC was obviously in between. Add an average as simple heuristic+ memuse += memuse / busyCycles;+ }+ busytime += System.currentTimeMillis() - timestamp;+ busyCycles++;+ } else {+ idleCycles++;+ }+ // interrupt loop if this is interrupted or supposed to be a one-time jobif ((!running) || (this.isInterrupted())) break;- busytime += (isBusy) ? System.currentTimeMillis() - timestamp : 0;- // interrupt loop if this is supposed to be a one-time jobif ((this.idlePause < 0) || (this.busyPause < 0)) break; // for one-time jobs// process scheduled pausetimestamp = System.currentTimeMillis();ratz((isBusy) ? this.busyPause : this.idlePause);idletime += System.currentTimeMillis() - timestamp;- if (isBusy) busyCycles++; else idleCycles++;} catch (Exception e) {// handle exceptions: thread must not die on any unexpected exceptions// if the exception is too bad it should call terminate()diff --git a/source/de/anomic/server/serverThread.java b/source/de/anomic/server/serverThread.javaindex 7f02df957..9439468af 100644--- a/source/de/anomic/server/serverThread.java+++ b/source/de/anomic/server/serverThread.java@@ -96,6 +96,9 @@ public interface serverThread {public long getExecTime();// returns the total time that this thread has worked so far+ public long getMemoryUse();+ // returns the sum of all memory usage differences before and after one busy job+public void setLog(serverLog log);// defines a log where process states can be written to