Commit 0d9685b0 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #32805 from caesarxuchao/more-gc-optimization

Automatic merge from submit-queue Add the uid in a delete event to the absentOwnerCache This is a small optimization to further reduce the traffic sent by the GC. In #31167, GC caches the non-existent owners when it processes the dirtyQueue. As discovered in #32571, there is still small inefficiency, because there are multiple goroutines processing the dirtyQueue, many of them might send a GET to the apiserver before the cache gets populated. This PR populates the cache when GC observes an object gets deleted, which happens before the processing of the dirtyQueue, so it avoids the simultaneous GET sent by the GC workers. cc @lavalamp
parents 15344153 d122de53
...@@ -410,6 +410,7 @@ func (p *Propagator) processEvent() { ...@@ -410,6 +410,7 @@ func (p *Propagator) processEvent() {
// the node's owners list. // the node's owners list.
p.removeDependentFromOwners(existingNode, removed) p.removeDependentFromOwners(existingNode, removed)
case event.eventType == deleteEvent: case event.eventType == deleteEvent:
p.gc.absentOwnerCache.Add(accessor.GetUID())
if !found { if !found {
glog.V(6).Infof("%v doesn't exist in the graph, this shouldn't happen", accessor.GetUID()) glog.V(6).Infof("%v doesn't exist in the graph, this shouldn't happen", accessor.GetUID())
return return
......
...@@ -298,8 +298,9 @@ func TestProcessEvent(t *testing.T) { ...@@ -298,8 +298,9 @@ func TestProcessEvent(t *testing.T) {
uidToNode: make(map[types.UID]*node), uidToNode: make(map[types.UID]*node),
}, },
gc: &GarbageCollector{ gc: &GarbageCollector{
dirtyQueue: workqueue.NewTimedWorkQueue(), dirtyQueue: workqueue.NewTimedWorkQueue(),
clock: clock.RealClock{}, clock: clock.RealClock{},
absentOwnerCache: NewUIDCache(2),
}, },
} }
for i := 0; i < len(scenario.events); i++ { for i := 0; i < len(scenario.events); i++ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment