-
Notifications
You must be signed in to change notification settings - Fork 509
refactor(cache): Integrate the Radix LRU cache with the --experimental-enable-optimized-metadata-cache flag #4872
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
base: radix-trie-cache
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,13 +88,14 @@ func benchmarkErasePrefix(b *testing.B, cache lru.Cache, prefixMap map[string][] | |
| } | ||
|
|
||
| i := 0 | ||
| b.ResetTimer() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| for b.Loop() { | ||
| b.StopTimer() // Timer must be running when b.Loop() evaluates, stop it for setup | ||
| prefix := prefixes[i%len(prefixes)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Can we do something like: |
||
|
|
||
| b.StartTimer() | ||
| cache.EraseEntriesWithGivenPrefix(prefix) | ||
| //reset the timer so that we only measure erasure time | ||
| b.StopTimer() | ||
| b.StopTimer() // Stop timer for cleanup | ||
|
|
||
| //restore the map | ||
| keysToRestore := prefixMap[prefix] | ||
|
|
@@ -103,6 +104,7 @@ func benchmarkErasePrefix(b *testing.B, cache lru.Cache, prefixMap map[string][] | |
| } | ||
|
|
||
| i++ | ||
| b.StartTimer() // Restart timer before b.Loop() evaluates | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -116,14 +118,23 @@ func runBenchmarks(b *testing.B, name string, depth int) { | |
| b.Run(name+"_MapLRU_Insert", func(b *testing.B) { | ||
| benchmarkInsert(b, lru.NewCache(capacity), keys) | ||
| }) | ||
| b.Run(name+"_RadixLRU_Insert", func(b *testing.B) { | ||
| benchmarkInsert(b, lru.NewRadixCache(capacity), keys) | ||
| }) | ||
|
|
||
| b.Run(name+"_MapLRU_Lookup", func(b *testing.B) { | ||
| benchmarkLookup(b, lru.NewCache(capacity), keys) | ||
| }) | ||
| b.Run(name+"_RadixLRU_Lookup", func(b *testing.B) { | ||
| benchmarkLookup(b, lru.NewRadixCache(capacity), keys) | ||
| }) | ||
|
|
||
| b.Run(name+"_MapLRU_ErasePrefix", func(b *testing.B) { | ||
| benchmarkErasePrefix(b, lru.NewCache(capacity), prefixMap, prefixes) | ||
| }) | ||
| b.Run(name+"_RadixLRU_ErasePrefix", func(b *testing.B) { | ||
| benchmarkErasePrefix(b, lru.NewRadixCache(capacity), prefixMap, prefixes) | ||
| }) | ||
| } | ||
|
|
||
| func BenchmarkLRU_Flat(b *testing.B) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,7 @@ func TestStatCacheMemoryWorkloads(t *testing.T) { | |
| for _, w := range workloads { | ||
| t.Logf("=== WORKLOAD: %s (%d files) ===", w, count) | ||
|
|
||
| // 1. StatCache | ||
| // 1. StatCache (Map) | ||
| paths := generatePaths(w, count) | ||
| baseMem := getMemStats() | ||
|
|
||
|
|
@@ -93,8 +93,24 @@ func TestStatCacheMemoryWorkloads(t *testing.T) { | |
| alloc := getMemStats() | ||
| pureMem := alloc - baseMem | ||
| runtime.KeepAlive(statCache) | ||
|
|
||
| t.Logf("%-20s Heap Used: %10.2f MB\n", "Map StatCache", float64(pureMem)/(1024*1024)) | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See if this can be converted to Table driven test or is it better to create 2 independent tests. |
||
| // 2. StatCache (Radix) | ||
| baseMemRadix := getMemStats() | ||
|
|
||
| sharedRadixCache := lru.NewRadixCache(capacity) | ||
| statRadixCache := metadata.NewStatCacheBucketView(sharedRadixCache, "") | ||
|
|
||
| for _, p := range paths { | ||
| statRadixCache.Insert(&gcs.MinObject{Name: p}, expiration) | ||
| } | ||
|
|
||
| allocRadix := getMemStats() | ||
| pureMemRadix := allocRadix - baseMemRadix | ||
| runtime.KeepAlive(statRadixCache) | ||
| runtime.KeepAlive(paths) | ||
|
|
||
| t.Logf("%-20s Heap Used: %10.2f MB\n", "StatCache", float64(pureMem)/(1024*1024)) | ||
| t.Logf("%-20s Heap Used: %10.2f MB\n", "Radix StatCache", float64(pureMemRadix)/(1024*1024)) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.