Skip to content
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

mvcc: separate synced/unsynced benchmarks #9796

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions mvcc/watchable_store_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,37 @@ func BenchmarkWatchableStoreTxnPut(b *testing.B) {
}
}

// BenchmarkWatchableStoreWatchSyncPut benchmarks the case of
// BenchmarkWatchableStoreWatchPutSync benchmarks the case of
// many synced watchers receiving a Put notification.
func BenchmarkWatchableStoreWatchSyncPut(b *testing.B) {
func BenchmarkWatchableStoreWatchPutSync(b *testing.B) {
benchmarkWatchableStoreWatchPut(b, true)
}

// BenchmarkWatchableStoreWatchPutUnsync benchmarks the case of
// many unsynced watchers receiving a Put notification.
func BenchmarkWatchableStoreWatchPutUnsync(b *testing.B) {
benchmarkWatchableStoreWatchPut(b, false)
}

func benchmarkWatchableStoreWatchPut(b *testing.B, synced bool) {
be, tmpPath := backend.NewDefaultTmpBackend()
s := newWatchableStore(zap.NewExample(), be, &lease.FakeLessor{}, nil)
defer cleanup(s, be, tmpPath)

k := []byte("testkey")
v := []byte("testval")

rev := int64(0)
if !synced {
// non-0 value to keep watchers in unsynced
rev = 1
}

w := s.NewWatchStream()
defer w.Close()
watchIDs := make([]WatchID, b.N)
for i := range watchIDs {
// non-0 value to keep watchers in unsynced
watchIDs[i], _ = w.Watch(0, k, nil, 1)
watchIDs[i], _ = w.Watch(0, k, nil, rev)
}

b.ResetTimer()
Expand Down