diff --git a/htroot/PerformanceQueues_p.html b/htroot/PerformanceQueues_p.html index 3de7f221f..fdbefd288 100644 --- a/htroot/PerformanceQueues_p.html +++ b/htroot/PerformanceQueues_p.html @@ -26,6 +26,7 @@ Short Mem
Cycles Sleep Time
per Cycle
(millis) Exec Time
per Busy-Cycle
(millis) +Memoy Use
per Busy-Cycle
(kbytes) Delay between
idle loops Delay between
busy loops Minimum of
Required Memory @@ -47,6 +48,7 @@ #[memscycles]# #[sleeppercycle]# #[execpercycle]# +#[memusepercycle]# milliseconds milliseconds bytes diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java index 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 threads long 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 values diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 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 ser getConfig("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.38 classicCache = new plasmaWordIndexClassicCacheMigration(plasmaPath, wordIndex); diff --git a/source/de/anomic/server/serverAbstractThread.java b/source/de/anomic/server/serverAbstractThread.java index 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 serverThrea private 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 serverThrea return 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 to this.log = log; @@ -227,6 +232,7 @@ public abstract class serverAbstractThread extends Thread implements serverThrea int 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 serverThrea if (rt.freeMemory() > memprereq) try { // do job timestamp = 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 job if ((!running) || (this.isInterrupted())) break; - busytime += (isBusy) ? System.currentTimeMillis() - timestamp : 0; - // interrupt loop if this is supposed to be a one-time job if ((this.idlePause < 0) || (this.busyPause < 0)) break; // for one-time jobs // process scheduled pause timestamp = 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.java index 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