memory-logging

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@804 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent ee347364d9
commit 2c7b490e30

@ -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>

@ -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

@ -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);

@ -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()

@ -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

Loading…
Cancel
Save