-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into raft-pre-vote
- Loading branch information
Showing
14 changed files
with
264 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package raft | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
) | ||
|
||
func BenchmarkStoreLogInMem(b *testing.B) { | ||
conf := DefaultConfig() | ||
conf.LocalID = "first" | ||
conf.HeartbeatTimeout = 50 * time.Millisecond | ||
conf.ElectionTimeout = 50 * time.Millisecond | ||
conf.LeaderLeaseTimeout = 50 * time.Millisecond | ||
conf.CommitTimeout = 5 * time.Millisecond | ||
conf.SnapshotThreshold = 100 | ||
conf.TrailingLogs = 10 | ||
conf.LogLevel = "OFF" | ||
raft := MakeRaft(b, conf, true) | ||
raft.logger.SetLevel(hclog.Off) | ||
|
||
NoErr(WaitFor(raft, Leader), b) | ||
|
||
applyAndWait := func(leader *RaftEnv, n, sz int) { | ||
// Do some commits | ||
var futures []ApplyFuture | ||
for i := 0; i < n; i++ { | ||
futures = append(futures, leader.raft.Apply(logBytes(i, sz), 0)) | ||
} | ||
for _, f := range futures { | ||
NoErr(WaitFuture(f), b) | ||
leader.logger.Debug("applied", "index", f.Index(), "size", sz) | ||
} | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
// Do some commits | ||
applyAndWait(raft, 100, 10) | ||
// Do a snapshot | ||
NoErr(WaitFuture(raft.raft.Snapshot()), b) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
module github.com/hashicorp/raft/fuzzy | ||
|
||
go 1.16 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/boltdb/bolt v1.3.1 // indirect | ||
github.com/hashicorp/go-hclog v1.5.0 | ||
github.com/hashicorp/go-msgpack v0.5.5 | ||
github.com/hashicorp/go-msgpack/v2 v2.1.1 | ||
github.com/hashicorp/raft v1.2.0 | ||
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea | ||
golang.org/x/sys v0.1.0 // indirect | ||
) | ||
|
||
require ( | ||
github.com/armon/go-metrics v0.4.1 // indirect | ||
github.com/boltdb/bolt v1.3.1 // indirect | ||
github.com/fatih/color v1.13.0 // indirect | ||
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect | ||
github.com/hashicorp/go-msgpack v0.5.5 // indirect | ||
github.com/hashicorp/golang-lru v0.5.0 // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
) | ||
|
||
replace github.com/hashicorp/raft => ../ |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.