Added code to track the largest event queue size and report it every
minute if so instructed. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3468 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -218,9 +218,22 @@ public class PresentsDObjectMgr
|
|||||||
*/
|
*/
|
||||||
protected void processUnit (Object unit)
|
protected void processUnit (Object unit)
|
||||||
{
|
{
|
||||||
long start = 0L;
|
long start = _timer.highResCounter();
|
||||||
if (_eventCount % UNIT_PROFILING_INTERVAL == 0) {
|
long freq = _timer.highResFrequency();
|
||||||
start = _timer.highResCounter();
|
|
||||||
|
if (REPORT_BIG_QUEUE) {
|
||||||
|
// keep track of the largest queue size we've seen
|
||||||
|
int queueSize = _evqueue.size();
|
||||||
|
if (queueSize > _maxQueueSize) {
|
||||||
|
_maxQueueSize = queueSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// report and reset our largest queue size once per minute
|
||||||
|
long startMillis = start * 1000 / freq;
|
||||||
|
if (_lastQueueReport - startMillis > 60 * 1000L) {
|
||||||
|
Log.info("Max dobj queue size " + _maxQueueSize);
|
||||||
|
_maxQueueSize = queueSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -245,19 +258,18 @@ public class PresentsDObjectMgr
|
|||||||
handleFatalError(unit, soe);
|
handleFatalError(unit, soe);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start != 0L) {
|
// compute the elapsed time in microseconds
|
||||||
long elapsed = _timer.highResCounter() - start;
|
long elapsed = _timer.highResCounter() - start;
|
||||||
|
elapsed = elapsed * 1000000 / freq;
|
||||||
|
|
||||||
// convert the elapsed time to microseconds
|
// report excessively long units
|
||||||
elapsed = elapsed * 1000000 / _timer.highResFrequency();
|
if (elapsed > 500000) {
|
||||||
|
Log.warning("Unit '" + StringUtil.safeToString(unit) +
|
||||||
// report excessively long units
|
" [" + StringUtil.shortClassName(unit) +
|
||||||
if (elapsed > 500000) {
|
"]' ran for " + (elapsed/1000) + "ms.");
|
||||||
Log.warning("Unit '" + StringUtil.safeToString(unit) +
|
}
|
||||||
" [" + StringUtil.shortClassName(unit) +
|
|
||||||
"]' ran for " + (elapsed/1000) + "ms.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (_eventCount % UNIT_PROFILING_INTERVAL == 0) {
|
||||||
// record the time spent processing this unit
|
// record the time spent processing this unit
|
||||||
String cname = StringUtil.shortClassName(unit);
|
String cname = StringUtil.shortClassName(unit);
|
||||||
UnitProfile uprof = (UnitProfile)_profiles.get(cname);
|
UnitProfile uprof = (UnitProfile)_profiles.get(cname);
|
||||||
@@ -973,12 +985,21 @@ public class PresentsDObjectMgr
|
|||||||
/** Used to profile our events and runnable units. */
|
/** Used to profile our events and runnable units. */
|
||||||
protected HashMap _profiles = new HashMap();
|
protected HashMap _profiles = new HashMap();
|
||||||
|
|
||||||
|
/** The largest queue size in the past minute. */
|
||||||
|
protected long _maxQueueSize;
|
||||||
|
|
||||||
|
/** The time at which we last reported our max queue size. */
|
||||||
|
protected long _lastQueueReport;
|
||||||
|
|
||||||
/** The frequency with which we take a profiling sample. */
|
/** The frequency with which we take a profiling sample. */
|
||||||
protected static final int UNIT_PROFILING_INTERVAL = 100;
|
protected static final int UNIT_PROFILING_INTERVAL = 100;
|
||||||
|
|
||||||
/** The default size of an oid list refs vector. */
|
/** The default size of an oid list refs vector. */
|
||||||
protected static final int DEFREFVEC_SIZE = 4;
|
protected static final int DEFREFVEC_SIZE = 4;
|
||||||
|
|
||||||
|
/** Whether to periodically report our largest event queue size. */
|
||||||
|
protected static final boolean REPORT_BIG_QUEUE = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This table maps event classes to helper methods that perform some
|
* This table maps event classes to helper methods that perform some
|
||||||
* additional processing for particular events.
|
* additional processing for particular events.
|
||||||
|
|||||||
Reference in New Issue
Block a user