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:
parent
7c0e1c4ef7
commit
501014a053
2 changed files with 25 additions and 8 deletions
14
bench/perf/Makefile
Normal file
14
bench/perf/Makefile
Normal 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)
|
|
@ -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(¬i, "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)
|
||||
|
|
Loading…
Add table
Reference in a new issue