Track and report some connection manager stats over a short historical
period so that we can see what sort of funny business is going on with the network thread when the process spikes up to 100% CPU. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3066 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// $Id: ConMgrStats.java,v 1.1 2004/08/04 02:31:18 mdb Exp $
|
||||
|
||||
package com.threerings.presents.data;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
/**
|
||||
* Used to track and report stats on the connection manager.
|
||||
*/
|
||||
public class ConMgrStats implements Streamable
|
||||
{
|
||||
/** The current index into the history arrays. */
|
||||
public int current;
|
||||
|
||||
/** The outgoing queue size. */
|
||||
public int[] outQueueSize;
|
||||
|
||||
/** The overflow queue size. */
|
||||
public int[] overQueueSize;
|
||||
|
||||
/** The number of bytes read. */
|
||||
public int[] bytesIn;
|
||||
|
||||
/** The number of bytes written. */
|
||||
public int[] bytesOut;
|
||||
|
||||
/** The number of messages read. */
|
||||
public int[] msgsIn;
|
||||
|
||||
/** The number of messages written. */
|
||||
public int[] msgsOut;
|
||||
|
||||
/** Advances the currently accumulating bucket and clears its
|
||||
* previous contents. */
|
||||
public void increment ()
|
||||
{
|
||||
current++;
|
||||
outQueueSize[current] = 0;
|
||||
overQueueSize[current] = 0;
|
||||
bytesIn[current] = 0;
|
||||
bytesOut[current] = 0;
|
||||
msgsIn[current] = 0;
|
||||
msgsOut[current] = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ConnectionManager.java,v 1.39 2004/06/03 09:02:47 mdb Exp $
|
||||
// $Id: ConnectionManager.java,v 1.40 2004/08/04 02:31:18 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server.net;
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
|
||||
import com.threerings.presents.data.ConMgrStats;
|
||||
import com.threerings.presents.net.AuthRequest;
|
||||
import com.threerings.presents.net.AuthResponse;
|
||||
import com.threerings.presents.net.DownstreamMessage;
|
||||
@@ -53,6 +54,15 @@ public class ConnectionManager extends LoopingThread
|
||||
_port = port;
|
||||
_selector = SelectorProvider.provider().openSelector();
|
||||
|
||||
// create our stats record
|
||||
_stats = new ConMgrStats();
|
||||
_stats.outQueueSize = new int[60];
|
||||
_stats.overQueueSize = new int[60];
|
||||
_stats.bytesIn = new int[60];
|
||||
_stats.bytesOut = new int[60];
|
||||
_stats.msgsIn = new int[60];
|
||||
_stats.msgsOut = new int[60];
|
||||
|
||||
// register as a "state of server" reporter
|
||||
PresentsServer.registerReporter(this);
|
||||
}
|
||||
@@ -89,6 +99,16 @@ public class ConnectionManager extends LoopingThread
|
||||
return _author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns our current runtime statistics. When the stats are fetched
|
||||
* the counters are rolled to the next bucket. 60 buckets are tracked.
|
||||
*/
|
||||
public synchronized ConMgrStats getStats ()
|
||||
{
|
||||
_stats.increment();
|
||||
return _stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified connection observer to the observers list.
|
||||
* Connection observers will be notified of connection-related
|
||||
@@ -382,10 +402,12 @@ public class ConnectionManager extends LoopingThread
|
||||
if (got != 0) {
|
||||
synchronized (this) {
|
||||
_bytesIn += got;
|
||||
_stats.bytesIn[_stats.current] += got;
|
||||
// we know that the handlers only report having
|
||||
// read bytes when they have a whole message, so
|
||||
// we can count thusly
|
||||
_msgsIn++;
|
||||
_stats.msgsIn[_stats.current]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,6 +492,8 @@ public class ConnectionManager extends LoopingThread
|
||||
{
|
||||
_msgsOut += msgs;
|
||||
_bytesOut += bytes;
|
||||
_stats.msgsOut[_stats.current] += msgs;
|
||||
_stats.bytesOut[_stats.current] += bytes;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -700,6 +724,9 @@ public class ConnectionManager extends LoopingThread
|
||||
/** Messages read and written in the last reporting period. */
|
||||
protected int _msgsIn, _msgsOut;
|
||||
|
||||
/** Our current runtime stats. */
|
||||
protected ConMgrStats _stats;
|
||||
|
||||
/** Used to create an overflow queue on the first partial write. */
|
||||
protected PartialWriteHandler _oflowHandler = new PartialWriteHandler() {
|
||||
public void handlePartialWrite (Connection conn, ByteBuffer msgbuf) {
|
||||
|
||||
Reference in New Issue
Block a user