From dbcd2f6dc2a4b842ebcfa5dbfc7990befa27267c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 18 Mar 2025 22:32:53 +0200 Subject: add race detector --- Makefile | 3 +++ internal/flamegraph/flamegraph.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fe8d281..3935361 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ generate: .PHONY: gobuild gobuild: $(GO) build -tags netgo -ldflags '-w -extldflags "-static"' -o ior ./cmd/ior/main.go +gobuild_race: + $(GO) build -tags netgo -ldflags '-w -extldflags "-static"' -race -o ior ./cmd/ior/main.go .PHONY: clean clean: @@ -69,3 +71,4 @@ inferno: prof: $(GO) tool pprof -pdf ./ior ior.cpuprofile > cpuprofile.pdf && evince cpuprofile.pdf & $(GO) tool pprof -pdf ./ior ior.memprofile > memprofile.pdf && evince memprofile.pdf & + diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go index 223389d..d5d7e96 100644 --- a/internal/flamegraph/flamegraph.go +++ b/internal/flamegraph/flamegraph.go @@ -21,7 +21,11 @@ func New() Flamegraph { Ch: make(chan *event.Pair, 4096), Done: make(chan struct{}), } - for range runtime.NumCPU() / 2 { + numWorkers := runtime.NumCPU() / 4 + if numWorkers == 0 { + numWorkers = 1 + } + for range numWorkers { f.workers = append(f.workers, newWorker()) } return f -- cgit v1.2.3