Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion hub/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"sync"

lru "github.com/hashicorp/golang-lru"
"k8s.io/klog/v2"
)

type Pool struct {
Expand All @@ -31,7 +32,15 @@
const PoolSize = 1024 // This number should match the max number of concurrent clusters handled

func NewPool(kvFactory func() KV) (*Pool, error) {
cache, err := lru.New(PoolSize)
// Log evictions so it's visible when the pool is undersized for the
// workload. With each registry now owning its own KV map (see
// NewKVMapFromKnown), an evicted registry just becomes garbage as
// in-flight goroutines release it — but any work it had buffered
// (e.g. recent RegisterGVR calls) is gone, so frequent evictions are
// worth surfacing.
cache, err := lru.NewWithEvict(PoolSize, func(key, _ interface{}) {

Check failure on line 41 in hub/pool.go

View workflow job for this annotation

GitHub Actions / k8s (v1.33.7)

File is not properly formatted (gofmt)

Check failure on line 41 in hub/pool.go

View workflow job for this annotation

GitHub Actions / k8s (v1.35.0)

File is not properly formatted (gofmt)
klog.V(2).InfoS("evicted cluster registry from pool", "uid", key)
})
if err != nil {
return nil, err
}
Expand Down
Loading