Open
Conversation
Author
|
did you finally have a look at this? |
Owner
|
Not yet, sorry. I'll take a look soon. |
|
Found this fork: https://github.com/arp242/zcache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a BST to the cache data structure. Insertions of new elements, deletions, and expiration changes are slower operations now (O(logn) instead of O(1)). However the bulk removal of expired objects is faster when expired elements are not "too many".
Examining the tradeoff between these two effects may be a bit tricky. The benchmarks that I introduced seem to indicate that this new version performs better than the original one whenever the bulk deletions remove less than 1% of the of the elements.
Here are my results:
original:
BenchmarkCacheGetExpiring-4 20000000 74.5 ns/op
BenchmarkCacheGetNotExpiring-4 50000000 37.7 ns/op
BenchmarkRWMutexMapGet-4 50000000 30.5 ns/op
BenchmarkRWMutexInterfaceMapGetStruct-4 20000000 84.2 ns/op
BenchmarkRWMutexInterfaceMapGetString-4 20000000 82.9 ns/op
BenchmarkCacheGetConcurrentExpiring-4 20000000 72.9 ns/op
BenchmarkCacheGetConcurrentNotExpiring-4 20000000 62.7 ns/op
BenchmarkRWMutexMapGetConcurrent-4 30000000 54.4 ns/op
BenchmarkCacheGetManyConcurrentExpiring-4 2000000000 66.6 ns/op
BenchmarkCacheGetManyConcurrentNotExpiring-4 30000000 65.7 ns/op
BenchmarkCacheSetExpiring-4 10000000 237 ns/op
BenchmarkCacheSetNotExpiring-4 10000000 201 ns/op
BenchmarkRWMutexMapSet-4 20000000 89.4 ns/op
BenchmarkCacheSetDelete-4 5000000 301 ns/op
BenchmarkRWMutexMapSetDelete-4 10000000 179 ns/op
BenchmarkCacheSetDeleteSingleLock-4 5000000 266 ns/op
BenchmarkRWMutexMapSetDeleteSingleLock-4 10000000 140 ns/op
BenchmarkIncrementInt-4 10000000 209 ns/op
BenchmarkDeleteExpiredLoop-4 500 2892388 ns/op
BenchmarkLargeCache01-4 1000000 27441 ns/op
BenchmarkLargeCache02-4 1000000 35324 ns/op
BenchmarkLargeCache05-4 1000000 14706 ns/op
BenchmarkLargeCache10-4 1000000 8612 ns/op
BenchmarkLargeCache20-4 1000000 5408 ns/op
BenchmarkLargeCache50-4 1000000 2729 ns/op
BenchmarkShardedCacheGetExpiring-4 20000000 111 ns/op
BenchmarkShardedCacheGetNotExpiring-4 20000000 69.7 ns/op
BenchmarkShardedCacheGetManyConcurrentExpiring-4 20000000 76.0 ns/op
BenchmarkShardedCacheGetManyConcurrentNotExpiring-4 20000000 68.5 ns/op
new:
BenchmarkCacheGetExpiring-4 20000000 75.3 ns/op
BenchmarkCacheGetNotExpiring-4 50000000 37.9 ns/op
BenchmarkRWMutexMapGet-4 50000000 33.8 ns/op
BenchmarkRWMutexInterfaceMapGetStruct-4 20000000 81.5 ns/op
BenchmarkRWMutexInterfaceMapGetString-4 20000000 80.3 ns/op
BenchmarkCacheGetConcurrentExpiring-4 20000000 60.4 ns/op
BenchmarkCacheGetConcurrentNotExpiring-4 20000000 63.1 ns/op
BenchmarkRWMutexMapGetConcurrent-4 30000000 57.3 ns/op
BenchmarkCacheGetManyConcurrentExpiring-4 2000000000 61.8 ns/op
BenchmarkCacheGetManyConcurrentNotExpiring-4 30000000 64.4 ns/op
BenchmarkCacheSetExpiring-4 2000000 856 ns/op
BenchmarkCacheSetNotExpiring-4 10000000 199 ns/op
BenchmarkRWMutexMapSet-4 20000000 92.6 ns/op
BenchmarkCacheSetDelete-4 3000000 491 ns/op
BenchmarkRWMutexMapSetDelete-4 10000000 176 ns/op
BenchmarkCacheSetDeleteSingleLock-4 3000000 444 ns/op
BenchmarkRWMutexMapSetDeleteSingleLock-4 10000000 144 ns/op
BenchmarkIncrementInt-4 10000000 213 ns/op
BenchmarkDeleteExpiredLoop-4 1000000 1712 ns/op
BenchmarkLargeCache01-4 1000000 8704 ns/op
BenchmarkLargeCache02-4 1000000 8561 ns/op
BenchmarkLargeCache05-4 1000000 8328 ns/op
BenchmarkLargeCache10-4 1000000 7837 ns/op
BenchmarkLargeCache20-4 1000000 7418 ns/op
BenchmarkLargeCache50-4 1000000 7702 ns/op
BenchmarkShardedCacheGetExpiring-4 20000000 109 ns/op
BenchmarkShardedCacheGetNotExpiring-4 20000000 67.4 ns/op
BenchmarkShardedCacheGetManyConcurrentExpiring-4 2000000000 50.9 ns/op
BenchmarkShardedCacheGetManyConcurrentNotExpiring-4 100000000 69.2 ns/op