summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/epoll/epoll.go
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-03-25 11:40:49 -0700
committerShentubot <shentubot@google.com>2019-03-25 11:41:50 -0700
commitddc05e3053e387be9c81aa98c621b6fc92b01000 (patch)
tree405eb7901958aec9a73d32eac1f58c2536e4f9cc /pkg/sentry/kernel/epoll/epoll.go
parentb81bfd6013ce871524e493272ac36b134f7fbbdf (diff)
epoll: use ilist:generic_list instead of ilist:ilist
ilist:generic_list works faster than ilist:ilist. Here is a beanchmark test to measure performance of epoll_wait, when readyList isn't empty. It shows about 30% better performance with these changes. Benchmark Time(ns) CPU(ns) Iterations Before: BM_EpollAllEvents 46725 46899 14286 After: BM_EpollAllEvents 33167 33300 18919 PiperOrigin-RevId: 240185278 Change-Id: I3e33f9b214db13ab840b91613400525de5b58d18
Diffstat (limited to 'pkg/sentry/kernel/epoll/epoll.go')
-rw-r--r--pkg/sentry/kernel/epoll/epoll.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/pkg/sentry/kernel/epoll/epoll.go b/pkg/sentry/kernel/epoll/epoll.go
index 502395f18..61c0fb7c5 100644
--- a/pkg/sentry/kernel/epoll/epoll.go
+++ b/pkg/sentry/kernel/epoll/epoll.go
@@ -21,7 +21,6 @@ import (
"sync"
"syscall"
- "gvisor.googlesource.com/gvisor/pkg/ilist"
"gvisor.googlesource.com/gvisor/pkg/refs"
"gvisor.googlesource.com/gvisor/pkg/sentry/context"
"gvisor.googlesource.com/gvisor/pkg/sentry/fs"
@@ -70,7 +69,7 @@ type FileIdentifier struct {
//
// +stateify savable
type pollEntry struct {
- ilist.Entry
+ pollEntryEntry
file *refs.WeakRef `state:"manual"`
id FileIdentifier `state:"wait"`
userData [2]int32
@@ -84,7 +83,7 @@ type pollEntry struct {
// struct, while state framework currently does not support such
// in-struct pointers. Instead, EventPoll will properly set this field
// in its loading logic.
- curList *ilist.List `state:"nosave"`
+ curList *pollEntryList `state:"nosave"`
}
// WeakRefGone implements refs.WeakRefUser.WeakRefGone.
@@ -133,9 +132,9 @@ type EventPoll struct {
// disabledList -- when the entry is disabled. This happens when
// a one-shot entry gets delivered via readEvents().
listsMu sync.Mutex `state:"nosave"`
- readyList ilist.List
- waitingList ilist.List
- disabledList ilist.List
+ readyList pollEntryList
+ waitingList pollEntryList
+ disabledList pollEntryList
}
// cycleMu is used to serialize all the cycle checks. This is only used when
@@ -189,7 +188,7 @@ func (e *EventPoll) eventsAvailable() bool {
e.listsMu.Lock()
for it := e.readyList.Front(); it != nil; {
- entry := it.(*pollEntry)
+ entry := it
it = it.Next()
// If the entry is ready, we know 'e' has at least one entry
@@ -225,14 +224,14 @@ func (e *EventPoll) Readiness(mask waiter.EventMask) waiter.EventMask {
// ReadEvents returns up to max available events.
func (e *EventPoll) ReadEvents(max int) []Event {
- var local ilist.List
+ var local pollEntryList
var ret []Event
e.listsMu.Lock()
// Go through all entries we believe may be ready.
for it := e.readyList.Front(); it != nil && len(ret) < max; {
- entry := it.(*pollEntry)
+ entry := it
it = it.Next()
// Check the entry's readiness. It it's not really ready, we