Split our reports into the default report and a separate report for the giant

morass of profiling data.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5709 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2009-04-06 21:13:59 +00:00
parent fd321d6f2d
commit 3b1024651a
3 changed files with 85 additions and 69 deletions
@@ -70,7 +70,7 @@ import static com.threerings.presents.Log.log;
*/
@Singleton
public class PresentsDObjectMgr
implements RootDObjectManager, RunQueue, ReportManager.Reporter
implements RootDObjectManager, RunQueue
{
/** Contains operational statistics that are tracked by the distributed object manager between
* {@link ReportManager.Reporter} intervals. The snapshot for the most recently completed
@@ -103,9 +103,39 @@ public class PresentsDObjectMgr
dummy.setManager(this);
_objects.put(0, new DObject());
// register ourselves as a state of server reporter and also tell the report manager that
// we're providing the runqueue for it to do its business
repmgr.registerReporter(this);
// register a couple of reports with the report manager
repmgr.registerReporter(ReportManager.DEFAULT_TYPE, new ReportManager.Reporter() {
public void appendReport (StringBuilder report, long now, long elapsed, boolean reset) {
report.append("* presents.PresentsDObjectMgr:\n");
int queueSize = _evqueue.size();
report.append("- Queue size: ").append(queueSize).append("\n");
report.append("- Max queue size: ").append(_current.maxQueueSize).append("\n");
report.append("- Units executed: ").append(_current.eventCount);
report.append(" (").append(1000*_current.eventCount/elapsed).append("/s)\n");
// roll over stats
if (reset) {
_recent = _current;
_current = new Stats();
_current.maxQueueSize = queueSize;
}
}
});
repmgr.registerReporter(ReportManager.PROFILE_TYPE, new ReportManager.Reporter() {
public void appendReport (StringBuilder report, long now, long elapsed, boolean reset) {
report.append("* presents.PresentsDObjectMgr:\n");
if (UNIT_PROF_ENABLED) {
report.append("- Unit profiles: ").append(_profiles.size()).append("\n");
for (Map.Entry<String, UnitProfile> entry : _profiles.entrySet()) {
report.append(" ").append(entry.getKey());
report.append(" ").append(entry.getValue()).append("\n");
}
} else {
report.append("- Unit profiles disabled.\n");
}
}
});
// also tell the report manager that we're providing the runqueue for it to do its business
repmgr.init(this);
// register our event helpers
@@ -546,32 +576,6 @@ public class PresentsDObjectMgr
return !_evqueue.hasElements();
}
// from interface ReportManager.Reporter
public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset)
{
report.append("* presents.PresentsDObjectMgr:\n");
int queueSize = _evqueue.size();
report.append("- Queue size: ").append(queueSize).append("\n");
report.append("- Max queue size: ").append(_current.maxQueueSize).append("\n");
report.append("- Units executed: ").append(_current.eventCount);
report.append(" (").append(1000*_current.eventCount/sinceLast).append("/s)\n");
if (UNIT_PROF_ENABLED) {
report.append("- Unit profiles: ").append(_profiles.size()).append("\n");
for (Map.Entry<String, UnitProfile> entry : _profiles.entrySet()) {
report.append(" ").append(entry.getKey());
report.append(" ").append(entry.getValue()).append("\n");
}
}
// roll over stats
if (reset) {
_recent = _current;
_current = new Stats();
_current.maxQueueSize = queueSize;
}
}
/**
* Tests if the event processing thread is still running. This is required by the
* ConnectionManager to ensure messages posted just before or during shutdown are sent.