Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 4 additions & 12 deletions rawnode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,9 @@ func BenchmarkRawNode(b *testing.B) {
}

func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {

const debug = false

s := newTestMemoryStorage(withPeers(peers...))
cfg := newTestConfig(1, 10, 1, s)
if !debug {
if !*benchDebug {
cfg.Logger = discardLogger // avoid distorting benchmark output
}
rn, err := NewRawNode(cfg)
Expand All @@ -1009,7 +1006,7 @@ func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {
for rn.HasReady() {
numReady++
rd := rn.Ready()
if debug {
if *benchDebug {
b.Log(DescribeReady(rd, nil))
}
if n := len(rd.CommittedEntries); n > 0 {
Expand All @@ -1019,7 +1016,7 @@ func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {
for _, m := range rd.Messages {
if m.GetType() == pb.MsgVote {
resp := &pb.Message{To: m.From, From: m.To, Term: m.Term, Type: pb.MsgVoteResp.Enum()}
if debug {
if *benchDebug {
b.Log(DescribeMessage(resp, nil))
}
rn.Step(resp)
Expand All @@ -1030,7 +1027,7 @@ func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {
idx = m.GetEntries()[n-1].GetIndex()
}
resp := &pb.Message{To: m.From, From: m.To, Type: pb.MsgAppResp.Enum(), Term: m.Term, Index: new(idx)}
if debug {
if *benchDebug {
b.Log(DescribeMessage(resp, nil))
}
rn.Step(resp)
Expand All @@ -1044,11 +1041,6 @@ func benchmarkRawNodeImpl(b *testing.B, peers ...uint64) {
rn.Campaign()
stabilize()

if debug {
// nolint:staticcheck
b.N = 1
}
Comment on lines -1047 to -1050

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to keep this code

#367 (comment)


var applied uint64
for i := 0; i < b.N; i++ {
if err := rn.Propose([]byte("foo")); err != nil {
Comment on lines 1044 to 1046

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a valid comment. Can you resolve this comment?

Expand Down
3 changes: 3 additions & 0 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package raft

import (
"flag"
Comment thread
ahrtr marked this conversation as resolved.
"fmt"
"math"
"strings"
Expand All @@ -27,6 +28,8 @@ import (
pb "go.etcd.io/raft/v3/raftpb"
)

var benchDebug = flag.Bool("bench.debug", false, "Debug logging in benchmarks.")

var testFormatter EntryFormatter = func(data []byte) string {
return strings.ToUpper(string(data))
}
Expand Down
Loading