Skip to content

Commit 34eddf9

Browse files
committed
Increase slowWriteTimer to 15ms and document why
1 parent 5d4f901 commit 34eddf9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pgconn/pgconn.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,13 @@ func (pgConn *PgConn) makeCommandTag(buf []byte) CommandTag {
17121712
// enterPotentialWriteReadDeadlock must be called before a write that could deadlock if the server is simultaneously
17131713
// blocked writing to us.
17141714
func (pgConn *PgConn) enterPotentialWriteReadDeadlock() {
1715-
pgConn.slowWriteTimer.Reset(10 * time.Millisecond)
1715+
// The time to wait is somewhat arbitrary. A Write should only take as long as the syscall and memcpy to the OS
1716+
// outbound network buffer unless the buffer is full (which potentially is a block). It needs to be long enough for
1717+
// the normal case, but short enough not to kill performance if a block occurs.
1718+
//
1719+
// In addition, on Windows the default timer resolution is 15.6ms. So setting the timer to less than that is
1720+
// ineffective.
1721+
pgConn.slowWriteTimer.Reset(15 * time.Millisecond)
17161722
}
17171723

17181724
// exitPotentialWriteReadDeadlock must be called after a call to enterPotentialWriteReadDeadlock.

0 commit comments

Comments
 (0)