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
Change slasher cache to LRU cache #5037
Conversation
slasher/cache/cache.go
Outdated
@@ -0,0 +1,73 @@ | |||
package cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps make the name cache.go
more specific, when person B comes in and implements a new cache for other functionality, they don't have to worry about changing both
Codecov Report
@@ Coverage Diff @@
## master #5037 +/- ##
=========================================
Coverage ? 14.87%
=========================================
Files ? 98
Lines ? 7389
Branches ? 0
=========================================
Hits ? 1099
Misses ? 6160
Partials ? 130 |
…slasher-change-cache
slasher/cache/span_cache.go
Outdated
|
||
// SaveAllToDB removes all keys from the SpanCache. | ||
func (c *EpochSpansCache) SaveAllToDB() { | ||
//c.cache.Keys() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, was working on that to replace the onEvict
risettro has. Will fill it in.
slasher/cache/span_cache.go
Outdated
} | ||
|
||
// Delete removes an epoch from the cache and returns if it existed or not. | ||
func (c *EpochSpansCache) Delete(epoch uint64) (present bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why (present bool)
? instead of bool?, doesn't look like the standard convention to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be confusing what the return bools mean without context, but it's mentioned in the comment too
slasher/detection/service.go
Outdated
@@ -83,11 +83,11 @@ func (ds *Service) Start() { | |||
|
|||
// The detection service runs detection on all historical | |||
// chain data since genesis. | |||
go ds.detectHistoricalChainData(ds.ctx) | |||
//go ds.detectHistoricalChainData(ds.ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why comment these out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented out in Raul's PR. Not functioning at the moment and gets in the way of testing live detection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test TestValidatorSpanMap_SaveOnEvict
doesn't test eviction any more as those parameters
setupDBDiffCacheSize(t testing.TB, cacheItems int64, maxCacheSize int64) *Store {
aren't being used
Part of #4836
This PR changes the risettro LFU cache to a LRU cache which better matches our use case.