summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-10-17 16:30:11 -0700
committerShentubot <shentubot@google.com>2018-10-17 16:31:15 -0700
commitf7419fec26d1fd0d12936cc44f2c3481bbade033 (patch)
tree8582991c841f6b0cfebc24f39571d89645d5a4ca /pkg
parente0bb94201f1edb6ce649192fe4a62e1781940b50 (diff)
Use generic ilist in Unix transport queue
This should improve performance. PiperOrigin-RevId: 217610560 Change-Id: I370f196ea2396f1715a460b168ecbee197f94d6c
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/socket/unix/transport/BUILD14
-rw-r--r--pkg/sentry/socket/unix/transport/queue.go9
-rw-r--r--pkg/sentry/socket/unix/transport/unix.go3
3 files changed, 19 insertions, 7 deletions
diff --git a/pkg/sentry/socket/unix/transport/BUILD b/pkg/sentry/socket/unix/transport/BUILD
index 75b5a2eb6..28038ce7f 100644
--- a/pkg/sentry/socket/unix/transport/BUILD
+++ b/pkg/sentry/socket/unix/transport/BUILD
@@ -1,6 +1,19 @@
package(licenses = ["notice"]) # Apache 2.0
load("//tools/go_stateify:defs.bzl", "go_library")
+load("//tools/go_generics:defs.bzl", "go_template_instance")
+
+go_template_instance(
+ name = "transport_message_list",
+ out = "transport_message_list.go",
+ package = "transport",
+ prefix = "message",
+ template = "//pkg/ilist:generic_list",
+ types = {
+ "Element": "*message",
+ "Linker": "*message",
+ },
+)
go_library(
name = "transport",
@@ -9,6 +22,7 @@ go_library(
"connectioned_state.go",
"connectionless.go",
"queue.go",
+ "transport_message_list.go",
"unix.go",
],
importpath = "gvisor.googlesource.com/gvisor/pkg/sentry/socket/unix/transport",
diff --git a/pkg/sentry/socket/unix/transport/queue.go b/pkg/sentry/socket/unix/transport/queue.go
index 203e31333..c4d7d863c 100644
--- a/pkg/sentry/socket/unix/transport/queue.go
+++ b/pkg/sentry/socket/unix/transport/queue.go
@@ -17,7 +17,6 @@ package transport
import (
"sync"
- "gvisor.googlesource.com/gvisor/pkg/ilist"
"gvisor.googlesource.com/gvisor/pkg/tcpip"
"gvisor.googlesource.com/gvisor/pkg/waiter"
)
@@ -33,7 +32,7 @@ type queue struct {
closed bool
used int64
limit int64
- dataList ilist.List
+ dataList messageList
}
// newQueue allocates and initializes a new queue.
@@ -61,7 +60,7 @@ func (q *queue) Close() {
func (q *queue) Reset() {
q.mu.Lock()
for cur := q.dataList.Front(); cur != nil; cur = cur.Next() {
- cur.(*message).Release()
+ cur.Release()
}
q.dataList.Reset()
q.used = 0
@@ -165,7 +164,7 @@ func (q *queue) Dequeue() (e *message, notify bool, err *tcpip.Error) {
notify = !q.bufWritable()
- e = q.dataList.Front().(*message)
+ e = q.dataList.Front()
q.dataList.Remove(e)
q.used -= e.Length()
@@ -189,7 +188,7 @@ func (q *queue) Peek() (*message, *tcpip.Error) {
return nil, err
}
- return q.dataList.Front().(*message).Peek(), nil
+ return q.dataList.Front().Peek(), nil
}
// QueuedSize returns the number of bytes currently in the queue, that is, the
diff --git a/pkg/sentry/socket/unix/transport/unix.go b/pkg/sentry/socket/unix/transport/unix.go
index 9a0de9a06..2934101a2 100644
--- a/pkg/sentry/socket/unix/transport/unix.go
+++ b/pkg/sentry/socket/unix/transport/unix.go
@@ -19,7 +19,6 @@ import (
"sync"
"sync/atomic"
- "gvisor.googlesource.com/gvisor/pkg/ilist"
"gvisor.googlesource.com/gvisor/pkg/tcpip"
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
"gvisor.googlesource.com/gvisor/pkg/waiter"
@@ -243,7 +242,7 @@ type BoundEndpoint interface {
//
// +stateify savable
type message struct {
- ilist.Entry
+ messageEntry
// Data is the Message payload.
Data buffer.View