From 5a13ea2ecd93e440946abae7bbaab6d55d0a30b4 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Wed, 12 Sep 2018 16:35:41 -0400 Subject: [PATCH] storage: create new raftEntryCache benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` name time/op EntryCache-4 3.00ms ± 9% EntryCacheClearTo-4 313µs ± 9% name alloc/op EntryCache-4 113kB ± 0% EntryCacheClearTo-4 8.31kB ± 0% name allocs/op EntryCache-4 2.02k ± 0% EntryCacheClearTo-4 14.0 ± 0% ``` Release note: None --- pkg/storage/entry_cache_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/storage/entry_cache_test.go b/pkg/storage/entry_cache_test.go index 91df197b55bc..5d876f299517 100644 --- a/pkg/storage/entry_cache_test.go +++ b/pkg/storage/entry_cache_test.go @@ -143,6 +143,29 @@ func TestEntryCacheEviction(t *testing.T) { } } +func BenchmarkEntryCache(b *testing.B) { + rangeID := roachpb.RangeID(1) + ents := make([]raftpb.Entry, 1000) + for i := range ents { + ents[i] = newEntry(uint64(i+1), 8) + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + b.StopTimer() + rec := newRaftEntryCache(8 * uint64(len(ents)*len(ents[0].Data))) + for i := roachpb.RangeID(0); i < 10; i++ { + if i != rangeID { + rec.addEntries(i, ents) + } + } + b.StartTimer() + rec.addEntries(rangeID, ents) + _, _, _, _ = rec.getEntries(nil, rangeID, 0, uint64(len(ents)-10), noLimit) + rec.clearTo(rangeID, uint64(len(ents)-10)) + } +} + func BenchmarkEntryCacheClearTo(b *testing.B) { rangeID := roachpb.RangeID(1) ents := make([]raftpb.Entry, 1000)