Skip to content

Commit

Permalink
Implement seq latency write bench for controller and replica
Browse files Browse the repository at this point in the history
Signed-off-by: Shuo Wu <shuo.wu@suse.com>
  • Loading branch information
shuo-wu committed Dec 4, 2023
1 parent b944734 commit bb18d43
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func RandStringRunes(n int) string {
func Bench(benchType string, thread int, size int64, writeAt, readAt func([]byte, int64) (int, error)) (output string, err error) {
lock := sync.Mutex{}

if thread != 1 && (benchType == "seq-latency-write" || benchType == "rand-latency-write" || benchType == "seq-latency-read" || benchType == "rand-latency-read") {
logrus.Warnf("Using single thread for latency related benchmark")
thread = 1
}

blockSize := 4096 // 4KB
if benchType == "bandwidth-read" || benchType == "bandwidth-write" {
blockSize = 1 << 20 // 1MB
Expand Down Expand Up @@ -379,6 +384,9 @@ func Bench(benchType string, thread int, size int64, writeAt, readAt func([]byte
case "bandwidth-write":
res := int(float64(size) / float64(duration) * 1000000000 / float64(1<<10))
output = fmt.Sprintf("instance bandwidth write %vKB/s, size %v, duration %vs, thread count %v", res, size, duration.Seconds(), thread)
case "seq-latency-write":
res := float64(duration) / 1000 / (float64(size) / float64(blockSize))
output = fmt.Sprintf("instance seq latency write %.2fus, size %v, duration %vs, thread count %v", res, size, duration.Seconds(), thread)
}
return output, nil
}

0 comments on commit bb18d43

Please sign in to comment.