Commit Graph

23 Commits (6f0ec4c470012f42f222949e2d89e7acb0753c80)

Author SHA1 Message Date
Jack Christensen 366440d40d Remove *msgReader.readOID 2017-02-17 07:40:06 -06:00
Jack Christensen 11b82b3ca4 msgReader implemented in terms of ChunkReader
This should substantially reduce memory allocations and memory copies.

It also means that PostgreSQL messages are always entirely buffered in memory
before processing begins. This simplifies the message processing code.

In particular, Conn.WaitForNotification is dramatically simplified by this
change.
2017-02-13 20:45:42 -06:00
Jack Christensen 7fbff4a495 Merge branch 'context' into v3-experimental 2017-02-12 15:13:47 -06:00
Jack Christensen 50b0bea9e5 msgReader pre-buffers messages when possible 2017-02-09 21:04:16 -06:00
Jack Christensen 855276e2cf Remove unused msgReader.Err() 2017-02-09 19:40:01 -06:00
Jack Christensen 39dad2b795 Merge branch 'master' into v3-experimental 2017-02-04 11:27:12 -06:00
Kris Wehner c88c110169 ReplicationConn refactor 2017-01-09 11:32:02 -08:00
Jack Christensen 93e5c68f69 Merge branch 'master' into v3-experimental 2016-12-10 12:21:08 -06:00
Manni Wood 55bd3a9134 Adds binary tid decode 2016-09-10 20:37:02 -04:00
Manni Wood 7dbfd4bf4b Switches oid to uint32 2016-09-01 22:55:18 -04:00
Martin Hamrle 9f6b99e332 Cleanups
Cleanups suggested by gometalinter tools.
2016-08-30 20:05:44 +02:00
Jack Christensen bb73d84279 Remove unnecessary buf from msgReader
Replace with bufio.Reader.Peek for short sizes
2016-08-08 17:01:01 -05:00
Jack Christensen 214443deb7 Rename Oid to OID 2016-08-02 13:31:55 -05:00
Jack Christensen 10cea2ec20 Use bufio.Reader.Discard instead of CopyN to ioutil.Discard 2016-04-30 14:11:08 -05:00
Jack Christensen 0f7bf19387 Add *Conn.SetLogLevel
Allow changing log level after connection is established. Because
log level and loggers can be set independently, it is now possible
to have a log level above none when there is a nil logger. This
means all log statements need to check for nil logger and an
appropriate log level. This check has been factored out into
*Conn.shouldLog.
2016-02-13 10:13:10 -06:00
Jack Christensen cffae7ff5d Add SetLogger to *Conn
Allow replacing logger after connection is established. Also
refactor internals of logging such that there is a log method that
adds the pid to all log calls instead of making a new logger object.
The reason for this is so pid will be logged regardless of whether
loggers are replaced and restored.
2016-02-12 17:49:04 -06:00
Jack Christensen beed0c0e5f Fix (r *msgReader) rxMsg() error guard clause
rxMsg() has a guard clause that checks if the msgReader has already
encountered an error. It should return that pre-existing error. It
was incorrectly returning a local `err` variable instead of `r.err`.
2016-01-29 16:30:15 -06:00
Jack Christensen 23c48c2f87 Add trace logging 2015-09-16 08:40:01 -05:00
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