Skip to content

runtime/pprof: 'Total samples' less than expected #45983

@shawndx

Description

@shawndx

What version of Go are you using (go version)?

$ go version
go version devel go1.17-1108cbe60b Thu May 6 02:21:55 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
....

What did you do?

on a machine with 16-core CPU (i7-10700K)

% go test -c runtime

4-core, multiple-round benchmarking delivers stable pprof numbers

% GOMAXPROCS=4 ./runtime.test -test.bench=ChanContended -test.run=none -test.benchtime=20s -test.cpuprofile=/tmp/p
% go tool pprof /tmp/p

File: runtime.test
Type: cpu
Time: May 6, 2021 at 10:48am (CST)
Duration: 28.53s, Total samples = 71.09s (249.20%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof)

8-core, multiple-round benchmarking delivers stable pprof numbers

% GOMAXPROCS=8 ./runtime.test -test.bench=ChanContended -test.run=none -test.benchtime=20s -test.cpuprofile=/tmp/p
% go tool pprof /tmp/p

File: runtime.test
Type: cpu
Time: May 6, 2021 at 10:41am (CST)
Duration: 31.09s, Total samples = 106.05s (341.07%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof)

16-core, multiple-round benchmarking delivers stable pprof numbers

% ./runtime.test -test.bench=ChanContended -test.run=none -test.benchtime=20s -test.cpuprofile=/tmp/p
% go tool pprof /tmp/p

File: runtime.test
Type: cpu
Time: May 6, 2021 at 10:47am (CST)
Duration: 37.10s, Total samples = 92.34s (248.92%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof)

What did you expect to see?

The 'Total samples' is near to GOMAXPROCS * 100% as the benchmark occupies all available cores.

If my assumption (expected 'total samples' near to GOMAXPROCS * 100%) is wrong, I'd like to learn what's the logic behind the gap and the variance.

What did you see instead?

'Total samples' is far less than expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions