-
Notifications
You must be signed in to change notification settings - Fork 71
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
Improve cachekv write performance #388
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #388 +/- ##
==========================================
- Coverage 54.81% 54.80% -0.01%
==========================================
Files 622 622
Lines 52177 52168 -9
==========================================
- Hits 28599 28590 -9
Misses 21495 21495
Partials 2083 2083
|
@@ -135,18 +135,9 @@ func (store *Store) Write() { | |||
// Clear the cache using the map clearing idiom | |||
// and not allocating fresh objects. | |||
// Please see https://bencher.orijtech.com/perfclinic/mapclearing/ | |||
store.cache.Range(func(key, value any) 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.
do these maps no longer behave in the idiomatic way? I gues that makes sense as we migrated from native go maps to sync maps, but just want to confirm
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.
Yeah, there's also a mutex to protect the writes
store/cachekv/store.go
Outdated
@@ -135,18 +135,9 @@ func (store *Store) Write() { | |||
// Clear the cache using the map clearing idiom |
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.
(i think this comment can probably go away now - LGTM 👍)
Describe your changes and provide context
This PR avoid the several O(N) operations to clear up the maps. Instead of looping through each item and delete them, it will be much more efficient to just reset to a new map.
Testing performed to validate your change
Tested in loadtest cluster and get performance improved (3ms -> 0.1ms)