]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Merge messageTypes{Sent,Posted} into torrent expvar
authorMatt Joiner <anacrolix@gmail.com>
Fri, 29 Jun 2018 12:10:21 +0000 (22:10 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 29 Jun 2018 12:10:21 +0000 (22:10 +1000)
connection.go
global.go

index 0c3bc1c4898de120ddd9346109ecd3fd16c0a46a..54297b56f6e83f75ba857fbc7a3bb721d0ea4711 100644 (file)
@@ -332,7 +332,7 @@ func (cn *connection) PeerHasPiece(piece int) bool {
 
 // Writes a message into the write buffer.
 func (cn *connection) Post(msg pp.Message) {
-       messageTypesPosted.Add(msg.Type.String(), 1)
+       torrent.Add(fmt.Sprintf("messages posted of type %s", msg.Type.String()), 1)
        // We don't need to track bytes here because a connection.w Writer wrapper
        // takes care of that (although there's some delay between us recording
        // the message, and the connection writer flushing it out.).
@@ -604,7 +604,8 @@ func (cn *connection) writer(keepAliveTimeout time.Duration) {
                        cn.fillWriteBuffer(func(msg pp.Message) bool {
                                cn.wroteMsg(&msg)
                                cn.writeBuffer.Write(msg.MustMarshalBinary())
-                               return cn.writeBuffer.Len() < 1<<16
+                               torrent.Add(fmt.Sprintf("messages filled of type %s", msg.Type.String()), 1)
+                               return cn.writeBuffer.Len() < 1<<16 // 64KiB
                        })
                }
                if cn.writeBuffer.Len() == 0 && time.Since(lastWrite) >= keepAliveTimeout {
@@ -923,7 +924,7 @@ func (c *connection) requestPendingMetadata() {
 }
 
 func (cn *connection) wroteMsg(msg *pp.Message) {
-       messageTypesSent.Add(msg.Type.String(), 1)
+       torrent.Add(fmt.Sprintf("messages written of type %s", msg.Type.String()), 1)
        cn.allStats(func(cs *ConnStats) { cs.wroteMsg(msg) })
 }
 
index bbec4b5f93965e0df4db45c61548af0412a5a799..ef7660fb26af21814d060e964303c1df66ed8dae 100644 (file)
--- a/global.go
+++ b/global.go
@@ -42,8 +42,6 @@ var (
        requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
 
        messageTypesReceived = expvar.NewMap("messageTypesReceived")
-       messageTypesSent     = expvar.NewMap("messageTypesSent")
-       messageTypesPosted   = expvar.NewMap("messageTypesPosted")
 
        // Track the effectiveness of Torrent.connPieceInclinationPool.
        pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")