Commit Graph

5 Commits (3ec870dc3c96ec2de164182870738be9f4cd7c88)

Author SHA1 Message Date
Blake Gentry 3ec870dc3c combine two small reads into one
There's no need to read 1 byte and then immediately read 4 more, rather
than just reading 5 bytes to begin with. Also, with this change rxMsg is
no longer swallowing an error from ReadByte.
2015-01-11 16:47:31 -08:00
Jack Christensen 4fbd76bee5 Make MsgReader private 2014-07-12 20:08:17 -05:00
Jack Christensen 009cdfa0b1 Use Scan and Encode* instead of ValueTranscoders 2014-07-09 07:56:48 -05:00
Jack Christensen 5b345e80e1 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.
2014-07-05 09:32:47 -05:00
Jack Christensen b25aea5c52 MsgReader no longer uses double buffering 2014-07-04 13:08:37 -05:00