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

Switch events history to use LRU cache instead of map #4444

Merged
merged 1 commit into from Feb 18, 2015

Conversation

saad-ali
Copy link
Member

Currently events history cache uses a map for tracking previously seen events. This means if the component (e.g. kubelet) runs for a long period of time and generates a ton of unique events, the hash table could grow very large in memory.

To prevent this from happening, this PR switches the events history cache to use a LRU cache. When the max num of entries is hit, it starts evicting the oldest entries.

I arbitrarily set the maxLruCacheEntries to 4096; let me know if you think this would be too high/low, etc.

Will update documentation (PR #4372) accordingly, once this is merged.

cc @dchen1107 @erictune

@@ -19,6 +19,7 @@ package record
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/groupcache/lru"
"sync"
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

History probably didn't need to be exposed outside the package? Consider making it lower-case?

@saad-ali
Copy link
Member Author

Thanks for the feedback Eric! PTAL. I think I'll create a follow-up PR, to break the cache out in to it's own package, and make it more generic.

@dchen1107
Copy link
Member

LGTM

I suggested that next time, you have dep library as a separate commit. Thanks!

erictune added a commit that referenced this pull request Feb 18, 2015
Switch events history to use LRU cache instead of map
@erictune erictune merged commit 7990b54 into kubernetes:master Feb 18, 2015
@saad-ali saad-ali deleted the eventsCacheLru branch February 18, 2015 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants