Skip to content

Commit 3c2a44d

Browse files
transport: when using write buffer pooling, use input size instead of size*2 (#6983)
1 parent 3ae77e6 commit 3c2a44d

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

dialoptions.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ func WithSharedWriteBuffer(val bool) DialOption {
154154
}
155155

156156
// WithWriteBufferSize determines how much data can be batched before doing a
157-
// write on the wire. The corresponding memory allocation for this buffer will
158-
// be twice the size to keep syscalls low. The default value for this buffer is
159-
// 32KB.
157+
// write on the wire. The default value for this buffer is 32KB.
160158
//
161159
// Zero or negative values will disable the write buffer such that each write
162160
// will be on underlying connection. Note: A Send call may not directly

internal/transport/http_util.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,9 @@ func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, sharedWriteBu
418418
return f
419419
}
420420

421-
func getWriteBufferPool(writeBufferSize int) *sync.Pool {
421+
func getWriteBufferPool(size int) *sync.Pool {
422422
writeBufferMutex.Lock()
423423
defer writeBufferMutex.Unlock()
424-
size := writeBufferSize * 2
425424
pool, ok := writeBufferPoolMap[size]
426425
if ok {
427426
return pool

server.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,9 @@ func SharedWriteBuffer(val bool) ServerOption {
249249
}
250250

251251
// WriteBufferSize determines how much data can be batched before doing a write
252-
// on the wire. The corresponding memory allocation for this buffer will be
253-
// twice the size to keep syscalls low. The default value for this buffer is
254-
// 32KB. Zero or negative values will disable the write buffer such that each
255-
// write will be on underlying connection.
256-
// Note: A Send call may not directly translate to a write.
252+
// on the wire. The default value for this buffer is 32KB. Zero or negative
253+
// values will disable the write buffer such that each write will be on underlying
254+
// connection. Note: A Send call may not directly translate to a write.
257255
func WriteBufferSize(s int) ServerOption {
258256
return newFuncServerOption(func(o *serverOptions) {
259257
o.writeBufferSize = s

0 commit comments

Comments
 (0)