2
0

Remove SelectValueTo

Benchmarks revealed that it is no longer performant enough to pull
its own wait. Using go_db_bench to copy JSON results to HTTP responses
it was ~20% *slower* for ~4BK responses and less than 10% faster for
+1MB responses.

The the performance problem was in io.CopyN / io.Copy. io.Copy
allocates a 32KB buffer if it doesn't have io.WriterTo or io.ReaderFrom
available. This extra alloc on every request was more expensive than
just reading the result into a string and writing it out to the response
body.

Tests indicated that if MsgReader implemented a custom Copy that used a
shared buffer it might have a few percent performance advantage. But the
additional complexity is not worth the performance gain.
This commit is contained in:
Jack Christensen
2014-07-05 09:25:13 -05:00
parent b27d828311
commit 5b345e80e1
7 changed files with 0 additions and 203 deletions
-17
View File
@@ -178,20 +178,3 @@ func (r *MsgReader) ReadString(count int32) string {
return string(b)
}
func (r *MsgReader) CopyN(w io.Writer, count int32) {
if r.err != nil {
return
}
r.msgBytesRemaining -= count
if r.msgBytesRemaining < 0 {
r.Fatal(errors.New("read past end of message"))
return
}
_, err := io.CopyN(w, r.reader, int64(count))
if err != nil {
r.Fatal(err)
}
}