From 7817fc50c9db71296f0df3fb0ff163131bb4c5ec Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 8 Oct 2014 15:20:43 +0200 Subject: [PATCH] added a high cpu cycle monitor to PerformanceQueues --- htroot/PerformanceQueues_p.html | 2 ++ htroot/PerformanceQueues_p.java | 6 ++++-- htroot/PerformanceQueues_p.xml | 1 + source/net/yacy/kelondro/workflow/AbstractBusyThread.java | 8 +++++++- source/net/yacy/kelondro/workflow/BusyThread.java | 8 +++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/htroot/PerformanceQueues_p.html b/htroot/PerformanceQueues_p.html index 670ea3c55..379ca9f2a 100644 --- a/htroot/PerformanceQueues_p.html +++ b/htroot/PerformanceQueues_p.html @@ -23,6 +23,7 @@ Idle
Cycles Busy
Cycles Short Mem
Cycles + High CPU
Cycles Sleep Time
per Cycle
(millis) Exec Time
per Busy-Cycle
(millis) Memory Use
per Busy-Cycle
(kbytes) @@ -46,6 +47,7 @@ #[idlecycles]# #[busycycles]# #[memscycles]# + #[highcpucycles]# #[sleeppercycle]# #[execpercycle]# #[memusepercycle]# diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java index 197e1441a..289bd3d5e 100644 --- a/htroot/PerformanceQueues_p.java +++ b/htroot/PerformanceQueues_p.java @@ -113,7 +113,7 @@ public class PerformanceQueues_p { int queuesize; threads = sb.threadNames(); int c = 0; - long idleCycles, busyCycles, memshortageCycles; + long idleCycles, busyCycles, memshortageCycles, highCPUCycles; // set profile? final boolean setProfile = (post != null && post.containsKey("submitdefault")); final boolean setDelay = (post != null) && (post.containsKey("submitdelay")); @@ -148,16 +148,18 @@ public class PerformanceQueues_p { idleCycles = thread.getIdleCycles(); busyCycles = thread.getBusyCycles(); memshortageCycles = thread.getOutOfMemoryCycles(); + highCPUCycles = thread.getHighCPUCycles(); prop.putNum("table_" + c + "_blocktime", blocktime / 1000); prop.putNum("table_" + c + "_blockpercent", 100 * blocktime / blocktime_total); prop.putNum("table_" + c + "_sleeptime", sleeptime / 1000); prop.putNum("table_" + c + "_sleeppercent", 100 * sleeptime / sleeptime_total); prop.putNum("table_" + c + "_exectime", exectime / 1000); prop.putNum("table_" + c + "_execpercent", 100 * exectime / exectime_total); - prop.putNum("table_" + c + "_totalcycles", idleCycles + busyCycles + memshortageCycles); + prop.putNum("table_" + c + "_totalcycles", idleCycles + busyCycles + memshortageCycles + highCPUCycles); prop.putNum("table_" + c + "_idlecycles", idleCycles); prop.putNum("table_" + c + "_busycycles", busyCycles); prop.putNum("table_" + c + "_memscycles", memshortageCycles); + prop.putNum("table_" + c + "_highcpucycles", highCPUCycles); prop.putNum("table_" + c + "_sleeppercycle", ((idleCycles + busyCycles) == 0) ? -1 : sleeptime / (idleCycles + busyCycles)); prop.putNum("table_" + c + "_execpercycle", (busyCycles == 0) ? -1 : exectime / busyCycles); prop.putNum("table_" + c + "_memusepercycle", (busyCycles == 0) ? -1 : memuse / busyCycles / 1024); diff --git a/htroot/PerformanceQueues_p.xml b/htroot/PerformanceQueues_p.xml index bef61d6d6..e603f347a 100644 --- a/htroot/PerformanceQueues_p.xml +++ b/htroot/PerformanceQueues_p.xml @@ -14,6 +14,7 @@ #[idlecycles]# #[busycycles]# #[memscycles]# + #[highcpucycles]# #[sleeppercycle]# #[execpercycle]# #[memusepercycle]# diff --git a/source/net/yacy/kelondro/workflow/AbstractBusyThread.java b/source/net/yacy/kelondro/workflow/AbstractBusyThread.java index dbe721aad..e720b8499 100644 --- a/source/net/yacy/kelondro/workflow/AbstractBusyThread.java +++ b/source/net/yacy/kelondro/workflow/AbstractBusyThread.java @@ -36,7 +36,7 @@ public abstract class AbstractBusyThread extends AbstractThread implements BusyT private final static ConcurrentLog log = new ConcurrentLog("BusyThread"); private long startup = 0, intermission = 0, idlePause = 0, busyPause = 0; private long idletime = 0, memprereq = 0; - private long idleCycles = 0, busyCycles = 0, outofmemoryCycles = 0; + private long idleCycles = 0, busyCycles = 0, outofmemoryCycles = 0, highCPUCycles = 0; private double loadprereq = 9; private boolean intermissionObedient = true; private final Object syncObject = new Object(); @@ -122,6 +122,11 @@ public abstract class AbstractBusyThread extends AbstractThread implements BusyT // a job execution was omitted because of memory shortage return this.outofmemoryCycles; } + + @Override + public long getHighCPUCycles() { + return this.highCPUCycles; + } @Override public final long getSleepTime() { @@ -182,6 +187,7 @@ public abstract class AbstractBusyThread extends AbstractThread implements BusyT logSystem("Thread '" + this.getName() + "' runs high load cycle. current: " + Memory.load() + " max.: " + loadprereq); timestamp = System.currentTimeMillis(); ratz(this.idlePause); + highCPUCycles++; idletime += System.currentTimeMillis() - timestamp; } else if (MemoryControl.request(memprereq, false)) try { // do job diff --git a/source/net/yacy/kelondro/workflow/BusyThread.java b/source/net/yacy/kelondro/workflow/BusyThread.java index f6e80894d..df1d00053 100644 --- a/source/net/yacy/kelondro/workflow/BusyThread.java +++ b/source/net/yacy/kelondro/workflow/BusyThread.java @@ -92,7 +92,13 @@ public interface BusyThread extends WorkflowThread { * because of memory shortage */ public long getOutOfMemoryCycles(); - + + /** + * @return the total number of cycles where a job execution was omitted + * because of too high CPU load + */ + public long getHighCPUCycles(); + /** * @return the total time that this thread has slept so far */