Record the maximum distributed object and invoker queue size every minute

to a specific stats log.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3594 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-06-13 18:16:56 +00:00
parent cf5b889be6
commit 457729fdcb
2 changed files with 55 additions and 8 deletions
@@ -28,6 +28,7 @@ import java.util.List;
import sun.misc.Perf;
import com.samskivert.util.AuditLogger;
import com.samskivert.util.HashIntMap;
import com.samskivert.util.Histogram;
import com.samskivert.util.Invoker;
@@ -93,12 +94,12 @@ public class PresentsDObjectMgr
}
/**
* Toggles whether or not we track and report our largest event queue
* size.
* Configures this manager with a log to which runtime statistics will
* be recorded.
*/
public void setReportQueueSize (boolean reportQueueSize)
public void setStatsLog (AuditLogger logger)
{
_reportQueueSize = reportQueueSize;
_statslog = logger;
}
// documentation inherited from interface
@@ -230,7 +231,7 @@ public class PresentsDObjectMgr
long start = _timer.highResCounter();
long freq = _timer.highResFrequency();
if (_reportQueueSize) {
if (_statslog != null) {
// keep track of the largest queue size we've seen
int queueSize = _evqueue.size();
if (queueSize > _maxQueueSize) {
@@ -241,7 +242,7 @@ public class PresentsDObjectMgr
long startMillis = start * 1000 / freq;
if (_nextQueueReport < startMillis) {
if (_nextQueueReport != 0L) {
Log.info("Max dobj queue size " + _maxQueueSize);
_statslog.log("max_dobj_queue_size " + _maxQueueSize);
_maxQueueSize = queueSize;
_nextQueueReport += 60 * 1000L;
@@ -1000,8 +1001,8 @@ public class PresentsDObjectMgr
/** Used to profile our events and runnable units. */
protected HashMap _profiles = new HashMap();
/** Whether or not we track and report our event queue size. */
protected boolean _reportQueueSize = false;
/** Used to report runtime statistics. */
protected AuditLogger _statslog;
/** The largest queue size in the past minute. */
protected long _maxQueueSize;
@@ -23,6 +23,7 @@ package com.threerings.presents.server;
import java.util.Iterator;
import com.samskivert.util.AuditLogger;
import com.samskivert.util.Histogram;
import com.samskivert.util.Invoker;
import com.samskivert.util.StringUtil;
@@ -49,6 +50,15 @@ public class PresentsInvoker extends Invoker
}
}
/**
* Configures this manager with a log to which runtime statistics will
* be recorded.
*/
public void setStatsLog (AuditLogger logger)
{
_statslog = logger;
}
/**
* Will do a sophisticated shutdown of both itself and the DObjectManager
* thread.
@@ -76,6 +86,32 @@ public class PresentsInvoker extends Invoker
}
}
// documentation inherited
protected void willInvokeUnit (Unit unit, long start)
{
super.willInvokeUnit(unit, start);
if (_statslog != null) {
// keep track of the largest queue size we've seen
int queueSize = _queue.size();
if (queueSize > _maxQueueSize) {
_maxQueueSize = queueSize;
}
// report and reset our largest queue size once per minute
if (_nextQueueReport < start) {
if (_nextQueueReport != 0L) {
_statslog.log("max_invoker_queue_size " + _maxQueueSize);
_maxQueueSize = queueSize;
_nextQueueReport += 60 * 1000L;
} else {
_nextQueueReport = start + 60 * 1000L;
}
}
}
}
/**
* This unit gets posted back and forth between the invoker and DObjectMgr
* until both of their queues are empty and they can both be safely
@@ -176,5 +212,15 @@ public class PresentsInvoker extends Invoker
protected static final int MAX_LOOPS = 10000;
}
/** The distributed object manager with which we interoperate. */
protected PresentsDObjectMgr _omgr;
/** Used to report runtime statistics. */
protected AuditLogger _statslog;
/** The largest queue size in the past minute. */
protected long _maxQueueSize;
/** The time at which we last reported our max queue size. */
protected long _nextQueueReport;
}