Additional diagnostics

Additional output of CPU usage for each module when stopping
This commit is contained in:
Douglas Gillespie 2024-03-13 11:47:34 +00:00
parent fc96c139d6
commit 6110ddb9d1
3 changed files with 21 additions and 1 deletions

View File

@ -1434,7 +1434,7 @@ public class PamController implements PamControllerInterface, PamSettings {
pamControlledUnits.get(iU).flushDataBlockBuffers(2000); pamControlledUnits.get(iU).flushDataBlockBuffers(2000);
} }
} }
dumpBufferStatus("In pamStopped, now idle", true); dumpBufferStatus("In pamStopped, now idle", false);
// wait here until the status has changed to Pam_Idle, so that we know // wait here until the status has changed to Pam_Idle, so that we know
// that we've really finished processing all data // that we've really finished processing all data

View File

@ -4296,6 +4296,9 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
* @param sayEmpties dump info even if a buffer is empty (otherwise, only ones that have stuff still) * @param sayEmpties dump info even if a buffer is empty (otherwise, only ones that have stuff still)
*/ */
public void dumpBufferStatus(String message, boolean sayEmpties) { public void dumpBufferStatus(String message, boolean sayEmpties) {
if (sayEmpties || unitsAdded > 0) {
System.out.printf("Datablock %s: Added %d data units\n", getLongDataName(), unitsAdded);
}
int nObs = countObservers(); int nObs = countObservers();
for (int i = 0; i < nObs; i++) { for (int i = 0; i < nObs; i++) {
PamObserver obs = getPamObserver(i); PamObserver obs = getPamObserver(i);

View File

@ -126,6 +126,8 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
private long cpuUsage; private long cpuUsage;
private long lastCPUCheckTime = System.currentTimeMillis(); private long lastCPUCheckTime = System.currentTimeMillis();
private double cpuPercent; private double cpuPercent;
private double totalCPU, peakCPU;
private int nCPU;
/** /**
* Flag for the process to say whether or not it's primary data connection * Flag for the process to say whether or not it's primary data connection
@ -140,6 +142,11 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
* Last received data unit - used for working out timing offsets. * Last received data unit - used for working out timing offsets.
*/ */
private PamDataUnit lastAcousticDataunit; private PamDataUnit lastAcousticDataunit;
/*
* diagnostic count of all data processed
*/
private int nDataProcessed;
// some flags and variables needed to deal with conversion from // some flags and variables needed to deal with conversion from
// milliseconds to samples and back // milliseconds to samples and back
// private boolean acousticDataSource = false; // private boolean acousticDataSource = false;
@ -742,6 +749,7 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
} }
// long cpuStart = SystemTiming.getProcessCPUTime(); // long cpuStart = SystemTiming.getProcessCPUTime();
long threadId = Thread.currentThread().getId(); long threadId = Thread.currentThread().getId();
nDataProcessed++;
long cpuStart = tmxb.getThreadCpuTime(threadId); long cpuStart = tmxb.getThreadCpuTime(threadId);
newData(o, arg); newData(o, arg);
if (processCheck != null) { if (processCheck != null) {
@ -762,6 +770,12 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
* get percent. Total is -9+3+2 = /!0^4 ! * get percent. Total is -9+3+2 = /!0^4 !
*/ */
cpuPercent = (double) cpuUsage / (now - lastCPUCheckTime) / 10000.; cpuPercent = (double) cpuUsage / (now - lastCPUCheckTime) / 10000.;
// these next two allow us to take an average cpu.
totalCPU += cpuPercent;
nCPU++;
// and hte max cpu (may always go to 100 at end ?)
peakCPU = Math.max(cpuPercent, peakCPU);
lastCPUCheckTime = now; lastCPUCheckTime = now;
cpuUsage = 0; cpuUsage = 0;
} }
@ -1073,6 +1087,9 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator {
* @param sayEmpties include info even if a buffer is empty. * @param sayEmpties include info even if a buffer is empty.
*/ */
public void dumpBufferStatus(String message, boolean sayEmpties) { public void dumpBufferStatus(String message, boolean sayEmpties) {
if (sayEmpties || nDataProcessed > 0) {
System.out.printf("Process %s: ran %d datas, peak CPU %3.1f%%, mean CPU %3.1f%%\n", this.getProcessName(), nDataProcessed, peakCPU, totalCPU/nCPU);
}
ArrayList<PamDataBlock> outputs = getOutputDataBlocks(); ArrayList<PamDataBlock> outputs = getOutputDataBlocks();
try { try {
for (PamDataBlock output : outputs) { for (PamDataBlock output : outputs) {