1
0
Fork 0
mirror of https://github.com/ii64/gouring.git synced 2025-04-26 05:42:48 +02:00

bench/perf: fix sqpoll result mismatch

Signed-off-by: Nugraha <richiisei@gmail.com>
This commit is contained in:
Xeffy Chen 2022-07-07 23:19:07 +07:00
parent 7c0e1c4ef7
commit 501014a053
Signed by: Xeffy
GPG key ID: E41C08AD390E7C49
2 changed files with 25 additions and 8 deletions
bench/perf

14
bench/perf/Makefile Normal file
View file

@ -0,0 +1,14 @@
alL: run
N := 100000
PERF_OPTS := -n $(N) -noti $(N)
build:
go build .
run: build
./perf $(PERF_OPTS) -pprofCpu pprof-nonsqpoll.cpu
./perf -sqpoll $(PERF_OPTS) -pprofCpu pprof-sqpoll.cpu
pprof:
go tool pprof -http=:9001 $(P)

View file

@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"os"
"runtime"
"runtime/pprof"
"syscall"
"time"
@ -12,8 +11,6 @@ import (
"github.com/ii64/gouring"
)
// usage: go tool pprof -http=:9001 pprof.cpu
var fs = flag.NewFlagSet("perf", flag.ExitOnError)
var (
@ -24,6 +21,8 @@ var (
N uint
noti uint
pprofCpuFilename = "pprof.cpu"
)
func init() {
@ -34,6 +33,8 @@ func init() {
fs.UintVar(&N, "n", 10_000, "N times")
fs.UintVar(&noti, "noti", 10_000, "Notify per attempt N")
fs.StringVar(&pprofCpuFilename, "pprofCpu", pprofCpuFilename, "pprof cpu output file")
}
func main() {
@ -60,7 +61,7 @@ func main() {
}
defer h.Close()
f, err := os.Create("pprof.cpu")
f, err := os.Create(pprofCpuFilename)
if err != nil {
panic(err)
}
@ -82,10 +83,12 @@ func main() {
}
for j = 0; j < entries; j++ {
sqe = h.GetSQE()
if sqe == nil { // spinning wait...
runtime.Gosched()
continue
for {
// sqe could be nil if SQ is already full so we spin until we got one
sqe = h.GetSQE()
if sqe != nil {
break
}
}
gouring.PrepNop(sqe)
sqe.UserData = uint64(i + j)