From: Matt Joiner Date: Sun, 2 Aug 2015 04:30:33 +0000 (+1000) Subject: Track connection writes and flushes X-Git-Tag: v1.0.0~1103 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=7ecc8108bf46ab96d75bf242b9ff8f36356cc79b;p=btrtrc.git Track connection writes and flushes Helps determine efficiency of the routine. --- diff --git a/connection.go b/connection.go index e1ae70b6..1d70c7a7 100644 --- a/connection.go +++ b/connection.go @@ -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