bench/perf: use of go sched

Signed-off-by: Nugraha <richiisei@gmail.com>
This commit is contained in:
Xeffy Chen 2022-07-07 23:31:18 +07:00
parent a5a0584e4d
commit 56090b50c8
Signed by: Xeffy
GPG key ID: E41C08AD390E7C49
2 changed files with 5 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"runtime"
"runtime/pprof" "runtime/pprof"
"syscall" "syscall"
"time" "time"
@ -89,6 +90,7 @@ func main() {
if sqe != nil { if sqe != nil {
break break
} }
runtime.Gosched()
} }
gouring.PrepNop(sqe) gouring.PrepNop(sqe)
sqe.UserData = uint64(i + j) sqe.UserData = uint64(i + j)

View file

@ -2,6 +2,7 @@ package gouring
import ( import (
"context" "context"
"runtime"
"syscall" "syscall"
"testing" "testing"
) )
@ -15,7 +16,7 @@ func BenchmarkQueueNop(b *testing.B) {
ts := []opt{ ts := []opt{
{"def-256", 256, IoUringParams{Flags: 0}}, {"def-256", 256, IoUringParams{Flags: 0}},
{"sqpoll-256-4-10000", 256, IoUringParams{Flags: IORING_SETUP_SQPOLL, SqThreadCpu: 8, SqThreadIdle: 10_000}}, {"sqpoll-256-4-10000", 256, IoUringParams{Flags: IORING_SETUP_SQPOLL, SqThreadCpu: 16, SqThreadIdle: 10_000}},
} }
consumer := func(h *IoUring, ctx context.Context, count int) { consumer := func(h *IoUring, ctx context.Context, count int) {
@ -60,6 +61,7 @@ func BenchmarkQueueNop(b *testing.B) {
if sqe != nil { if sqe != nil {
break break
} }
runtime.Gosched()
} }
PrepNop(sqe) PrepNop(sqe)
sqe.UserData = uint64(i + int(j)) sqe.UserData = uint64(i + int(j))