From 7ecc8108bf46ab96d75bf242b9ff8f36356cc79b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 2 Aug 2015 14:30:33 +1000 Subject: [PATCH] Track connection writes and flushes Helps determine efficiency of the routine. --- connection.go | 5 +++++ 1 file changed, 5 insertions(+) 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 -- 2.48.1