Text of github.com › golang › go › issues › 57722 as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

cmd/pprof: macOS 12.6.1 profile overcounts system calls (again) · Issue #57722 · golang/go · GitHub

Skip to content You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert cmd/pprof: macOS 12.6.1 profile overcounts system calls (again) #57722 New issue Copy link New issue Copy link Open Open cmd/pprof: macOS 12.6.1 profile overcounts system calls (again) #57722 Copy link Assignees Labels NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin compiler/runtime Issues related to the Go compiler and/or runtime. Issues related to the Go compiler and/or runtime. Milestone Go1.28 Description felixge opened on Jan 10, 2023 Issue body actions What version of Go are you using ( go version )? $ go version go version go1.19.4 darwin/arm64 This is on macOS 12.6.1 with an M1 chip, but the problem seems to affect Intel as well .

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="auto" GOARCH="arm64" GOBIN="" GOCACHE="/Users/MyUser/Library/Caches/go-build" GOENV="/Users/MyUser/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="-count=1" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/MyUser/go/pkg/mod" GONOPROXY="github.com/MyOrg" GONOSUMDB="github.com/MyOrg,go.myorg.io" GOOS="darwin" GOPATH="/Users/MyUser/go" GOPRIVATE="github.com/MyOrg" GOPROXY="binaries.myorg.io,https://proxy.golang.org,direct" GOROOT="/opt/homebrew/Cellar/go/1.19.4/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.4/libexec/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.19.4" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/MyUser/go/src/github.com/felixge/macos-profiler-bias/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0t/nwrdnfnd2mjdgr0z_p_f6xww0000gq/T/go-build3012663781=/tmp/go-build -gno-record-gcc-switches -fno-common" What did you do?

Create a CPU profile of a CPU-bound workload that is interleaved with short system calls. For example TestInterleavedIO is a reproducer that is compressing a 250MB file containing random data. What did you expect to see? A profile that is similar to the one shown below for linux. Most of time should be spent on gzip compression, and a little bit on syscalls. What did you see instead? On macOS the majority of time is attributed to read and write syscalls.

The gzip compression is barely showing up at all. Sanity Check TestSequentialIO implements the same workload, but instead of interleaved I/O, it does one big read first, followed by gzip compression, followed by a big write. As expected, Linux produces a profile dominated by gzip compression. And macOS now shows the right profile too. Conclusion macOS setitimer(2) seems to bias towards syscalls. This issue was reported and fixed in the past, see #17406 (2016) and #6047 (2013).

So this could be a macOS regression. I've uploaded all code, pprofs and screenshots to this google drive folder . Reacted by Ivo Anjo, Bryan Boreham, Prashant V, Anatole Beuzon, Filippo Valsorda, Patrik Lundin, Martin Czygan, TIm, Tobias Grieger, Yury Smolski and 3 more Reacted by Yury Smolski Activity Next gopherbot added compiler/runtime Issues related to the Go compiler and/or runtime. Issues related to the Go compiler and/or runtime. on Jan 10, 2023 cbedard commented on Jan 10, 2023 cbedard on Jan 10, 2023 Contributor More actions Testing on an Intel MacOS (MacOS 12.6.1) go version go version go version go1.19.4 darwin/amd64 go env go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/cameron.bedard/Library/Caches/go-build" GOENV="/Users/cameron.bedard/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/cameron.bedard/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/cameron.bedard/go" GOPRIVATE="" GOPROXY=" https://proxy.golang.org,direct " GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.19.4" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zs/r6mt7f1n66n9mw2rz8f9w2540000gp/T/go-build1170536968=/tmp/go-build -gno-record-gcc-switches -fno-common" I'm a bit of a go noob (start during advent of code lol), so I wasn't able to set up the UI you used but my IDE's built in pprof output looks similar to yours.

If you want the matching profiler UI and send me a how-to link I can set it up :) TestInterleavedIO TestSequentialIO Reacted by Felix Geisendörfer felixge commented on Jan 10, 2023 felixge on Jan 10, 2023 Contributor Author More actions @cbedard thanks, this looks like Intel Macs have the same issue. The UI doesn't matter, this is fine :). felixge changed the title [-] cmd/pprof: macOS 12.6.1 (M1) profile overcounts system calls (again) [/-] [+] cmd/pprof: macOS 12.6.1 profile overcounts system calls (again) [/+] on Jan 10, 2023 cagedmantis added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. on Jan 11, 2023 cagedmantis commented on Jan 11, 2023 cagedmantis on Jan 11, 2023 Contributor More actions @golang/runtime prattmic commented on Jan 11, 2023 prattmic on Jan 11, 2023 Member More actions It would not surprise me if darwin has unfair SIGPROF delivery. e.g., if the system call return path updates the CPU timers, it may be more likely to trigger overflow and deliver SIGPROF to itself vs threads that do not make system calls. prattmic commented on Jan 11, 2023 prattmic on Jan 11, 2023 Member More actions I think this could be tested with a simple C program.

Two threads, one running a busy loop, the other with a busy loop that makes a system call. Do they both receive ~50% of SIGPROF signals? cherrymui commented on Jan 11, 2023 cherrymui on Jan 11, 2023 Member More actions I haven't read the sample code. Just wonder, for the "interleaved" case, are the compression and I/O running concurrently on different goroutines/threads, or they are on the same thread but just interleaved?

If the latter, do you know what frequency or time period the interleaving is, and is it faster than the profile sampling frequency (100 Hz)? Thanks. prattmic added this to Go Compiler / Runtime / Command on Jan 11, 2023 felixge commented on Jan 11, 2023 felixge on Jan 11, 2023 Contributor Author More actions I haven't read the sample code. Just wonder, for the "interleaved" case, are the compression and I/O running concurrently on different goroutines/threads, or they are on the same thread but just interleaved?

It's the latter. But I suspect that there could be concurrent/parallel read-ahead happening on the OS level. If the latter, do you know what frequency or time period the interleaving is, and is it faster than the profile sampling frequency (100 Hz)? Thanks. According to the trace (shown below), the workload issues 53k syscalls in 3.7s, so at ~14kHz it's much faster than the profiling frequency. It would not surprise me if darwin has unfair SIGPROF delivery. e.g., if the system call return path updates

The rest of this page is on the live site.