Change segment queue limit to be of fixed size.

Netstack sets the unprocessed segment queue size to match the receive
buffer size. This is not required as this queue only needs to hold enough
for a short duration before the endpoint goroutine can process it.

Updates #230

PiperOrigin-RevId: 250976323
This commit is contained in:
Bhasker Hariharan
2019-05-31 16:17:33 -07:00
committed by Shentubot
parent 132bf68de4
commit 033f96cc93
4 changed files with 8 additions and 8 deletions
+1 -3
View File
@@ -335,7 +335,7 @@ func newEndpoint(stack *stack.Stack, netProto tcpip.NetworkProtocolNumber, waite
e.probe = p
}
e.segmentQueue.setLimit(2 * e.rcvBufSize)
e.segmentQueue.setLimit(MaxUnprocessedSegments)
e.workMu.Init()
e.workMu.Lock()
e.tsOffset = timeStampOffset()
@@ -757,8 +757,6 @@ func (e *endpoint) SetSockOpt(opt interface{}) *tcpip.Error {
}
e.rcvListMu.Unlock()
e.segmentQueue.setLimit(2 * size)
e.notifyProtocolGoroutine(mask)
return nil
+1 -1
View File
@@ -163,7 +163,7 @@ func (e *endpoint) loadState(state endpointState) {
// afterLoad is invoked by stateify.
func (e *endpoint) afterLoad() {
e.stack = stack.StackFromEnv
e.segmentQueue.setLimit(2 * e.rcvBufSize)
e.segmentQueue.setLimit(MaxUnprocessedSegments)
e.workMu.Init()
state := e.state
+4
View File
@@ -48,6 +48,10 @@ const (
// MaxBufferSize is the largest size a receive and send buffer can grow to.
maxBufferSize = 4 << 20 // 4MB
// MaxUnprocessedSegments is the maximum number of unprocessed segments
// that can be queued for a given endpoint.
MaxUnprocessedSegments = 300
)
// SACKEnabled option can be used to enable SACK support in the TCP
+2 -4
View File
@@ -16,8 +16,6 @@ package tcp
import (
"sync"
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
)
// segmentQueue is a bounded, thread-safe queue of TCP segments.
@@ -58,7 +56,7 @@ func (q *segmentQueue) enqueue(s *segment) bool {
r := q.used < q.limit
if r {
q.list.PushBack(s)
q.used += s.data.Size() + header.TCPMinimumSize
q.used++
}
q.mu.Unlock()
@@ -73,7 +71,7 @@ func (q *segmentQueue) dequeue() *segment {
s := q.list.Front()
if s != nil {
q.list.Remove(s)
q.used -= s.data.Size() + header.TCPMinimumSize
q.used--
}
q.mu.Unlock()