]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Track connection writes and flushes
authorMatt Joiner <anacrolix@gmail.com>
Sun, 2 Aug 2015 04:30:33 +0000 (14:30 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 2 Aug 2015 04:30:33 +0000 (14:30 +1000)
Helps determine efficiency of the routine.

connection.go

index e1ae70b6d60ac8e72e4207db4b8df497bc0dd730..1d70c7a7998de34e146d455adb86cea60ac08b55 100644 (file)
@@ -431,6 +431,9 @@ func (c *connection) SetInterested(interested bool) {
        c.Interested = interested
 }
 
+var connectionWriterFlush = expvar.NewInt("connectionWriterFlush")
+var connectionWriterWrite = expvar.NewInt("connectionWriterWrite")
+
 // Writes buffers to the socket from the write channel.
 func (conn *connection) writer() {
        // Reduce write syscalls.
@@ -450,6 +453,7 @@ func (conn *connection) writer() {
                        if !ok {
                                return
                        }
+                       connectionWriterWrite.Add(1)
                        _, err := buf.Write(b)
                        if err != nil {
                                conn.Close()
@@ -458,6 +462,7 @@ func (conn *connection) writer() {
                case <-conn.closing:
                        return
                case <-notEmpty:
+                       connectionWriterFlush.Add(1)
                        err := buf.Flush()
                        if err != nil {
                                return