Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary copies in cacher #40735

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions staging/src/k8s.io/apiserver/pkg/storage/cacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func (c *errWatcher) Stop() {
type cacheWatcher struct {
sync.Mutex
copier runtime.ObjectCopier
input chan watchCacheEvent
input chan *watchCacheEvent
result chan watch.Event
done chan struct{}
filter watchFilterFunc
Expand All @@ -763,7 +763,7 @@ type cacheWatcher struct {
func newCacheWatcher(copier runtime.ObjectCopier, resourceVersion uint64, chanSize int, initEvents []*watchCacheEvent, filter watchFilterFunc, forget func(bool)) *cacheWatcher {
watcher := &cacheWatcher{
copier: copier,
input: make(chan watchCacheEvent, chanSize),
input: make(chan *watchCacheEvent, chanSize),
result: make(chan watch.Event, chanSize),
done: make(chan struct{}),
filter: filter,
Expand Down Expand Up @@ -800,7 +800,7 @@ var timerPool sync.Pool
func (c *cacheWatcher) add(event *watchCacheEvent, budget *timeBudget) {
// Try to send the event immediately, without blocking.
select {
case c.input <- *event:
case c.input <- event:
return
default:
}
Expand All @@ -820,7 +820,7 @@ func (c *cacheWatcher) add(event *watchCacheEvent, budget *timeBudget) {
defer timerPool.Put(t)

select {
case c.input <- *event:
case c.input <- event:
stopped := t.Stop()
if !stopped {
// Consume triggered (but not yet received) timer event
Expand Down Expand Up @@ -928,7 +928,7 @@ func (c *cacheWatcher) process(initEvents []*watchCacheEvent, resourceVersion ui
}
// only send events newer than resourceVersion
if event.ResourceVersion > resourceVersion {
c.sendWatchCacheEvent(&event)
c.sendWatchCacheEvent(event)
}
}
}
Expand Down