bench/perf: handle interrupt from iouring enter

Other adjustments:
 * Fix miss results, using `SeenCqe` to pop CQ entry.
 * Increase sqpoll thread cpu to 16.
 * Fix CQE/SQE to Cqe/Sqe function name.
 * Fix UserData usage.

Benchmark:
 * Increase number of N to 10_000_000
This commit is contained in:
Xeffy Chen 2022-07-28 19:48:32 +07:00
parent 0fee4d7a7f
commit 98f78a3b9f
Signed by: Xeffy
GPG key ID: E41C08AD390E7C49
2 changed files with 17 additions and 9 deletions

View file

@ -1,10 +1,14 @@
alL: run alL: run
N := 100000 N := 10000000
PERF_OPTS := -n $(N) -noti $(N) PERF_OPTS := -n $(N) -noti 5000000
GCFLAGS := $(GCFLAGS)
#GCFLAGS += -m=2
#GCFLAGS += -l=4
build: build:
go build . go build -gcflags="$(GCFLAGS)" .
run: build run: build
./perf $(PERF_OPTS) -pprofCpu pprof-nonsqpoll.cpu ./perf $(PERF_OPTS) -pprofCpu pprof-nonsqpoll.cpu

View file

@ -29,8 +29,8 @@ var (
func init() { func init() {
fs.UintVar(&entries, "entries", 256, "Entries") fs.UintVar(&entries, "entries", 256, "Entries")
fs.BoolVar(&sqPoll, "sqpoll", false, "Enable SQPOLL") fs.BoolVar(&sqPoll, "sqpoll", false, "Enable SQPOLL")
fs.UintVar(&sqThreadCpu, "sqthreadcpu", 4, "SQ Thread CPU") fs.UintVar(&sqThreadCpu, "sqthreadcpu", 16, "SQ Thread CPU")
fs.UintVar(&sqThreadIdle, "sqthreadidle", 10_000, "SQ Thread idle") fs.UintVar(&sqThreadIdle, "sqthreadidle", 10_000, "SQ Thread idle") // milliseconds
fs.UintVar(&N, "n", 10_000, "N times") fs.UintVar(&N, "n", 10_000, "N times")
fs.UintVar(&noti, "noti", 10_000, "Notify per attempt N") fs.UintVar(&noti, "noti", 10_000, "Notify per attempt N")
@ -86,14 +86,14 @@ func main() {
for j = 0; j < entries; j++ { for j = 0; j < entries; j++ {
for { for {
// sqe could be nil if SQ is already full so we spin until we got one // sqe could be nil if SQ is already full so we spin until we got one
sqe = h.GetSQE() sqe = h.GetSqe()
if sqe != nil { if sqe != nil {
break break
} }
runtime.Gosched() runtime.Gosched()
} }
gouring.PrepNop(sqe) gouring.PrepNop(sqe)
sqe.UserData = uint64(i + j) sqe.UserData.SetUint64(uint64(i + j))
} }
submitted, err = h.Submit() submitted, err = h.Submit()
if err != nil { if err != nil {
@ -105,7 +105,10 @@ func main() {
} }
for j = 0; j < entries; j++ { for j = 0; j < entries; j++ {
err = h.WaitCQE(&cqe) err = h.WaitCqe(&cqe)
if err == syscall.EINTR {
continue
}
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -115,7 +118,8 @@ func main() {
if cqe.Res < 0 { if cqe.Res < 0 {
panic(syscall.Errno(-cqe.Res)) panic(syscall.Errno(-cqe.Res))
} }
_ = cqe
h.SeenCqe(cqe)
} }
} }
_ = submitted _ = submitted