pprof source and disasm views overcount recursive functions
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- go
- Lĩnh vực
- performance, tooling
Hướng nghiên cứu
Bắt đầu bằng cách kiểm tra internal/report/source.go tại dòng được tham chiếu và tái hiện profile đệ quy fac bằng go tool pprof, so sánh trang Sources với list fac. Theo dõi cách các sample tích lũy được tổng hợp cho các lời gọi đệ quy trong các chế độ xem mã nguồn và disassembly. Hoàn tất khi các hàm đệ quy không còn báo cáo phần trăm hoặc thời gian tích lũy vượt quá tổng profile.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What version of pprof are you using?
go tool pprof with go1.18.3.
Full go env output
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/keyhan/.cache/go-build" GOENV="/home/keyhan/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/keyhan/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/keyhan/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/snap/go/9848" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/snap/go/9848/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18.3" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" 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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2938140119=/tmp/go-build -gno-record-gcc-switches"
What operating system and processor architecture are you using?
Linux, x86-64 Intel.
What did you do?
I opened the attached profile with go tool pprof -http=: fac.pb.gz,
and navigated to the "Sources" page. Here is the output:

As you can see, it is claimed that fac took 6193% of the total time.
It is also said that it took 150 seconds, which is wrong since the
program took only a couple of seconds.
The issue also occurs with the command line version, although strangely
the output is better.
(pprof) list fac
Total: 2.43s
ROUTINE ======================== main.fac in /home/keyhan/exgo/e.go
2.43s 3.34s (flat, cum) 137.45% of Total
. . 2:
. . 3:import "os"
. . 4:import "log"
. . 5:import "runtime/pprof"
. . 6:
850ms 850ms 7:func fac(n uint64) uint64 {
60ms 60ms 8: if n == 0 {
. . 9: return 1
. . 10: } else {
1.52s 2.43s 11: return n * fac(n - 1)
. . 12: }
. . 13:}
. . 14:
. . 15:func main() {
. . 16: f, err := os.Create("example.pb.gz")
What did you expect to see?
cum% should not be more than 100%.
What did you see instead?
cum% is claimed to be 6193%.
Root cause(?)
I believe the root cause is this line of code:
This is wrong, since the cumulative time spent in the current function
is not fns.Sum() if the function calls itself recursively. In those
cases some nodes will be counted multiple times.
Source Code
package main
import "os"
import "log"
import "runtime/pprof"
func fac(n uint64) uint64 {
if n == 0 {
return 1
} else {
return n * fac(n - 1)
}
}
func main() {
f, err := os.Create("example.pb.gz")
if err != nil {
log.Fatal("could not create CPU profile: ", err)
}
defer f.Close() // error handling omitted for example
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatal("could not start CPU profile: ", err)
}
defer pprof.StopCPUProfile()
for i := 1; i <= 1e6; i++ {
fac(1000)
}
}
- Ngôn ngữ chính
- Go
- Star
- 9.3k
- Fork
- 683
- Merge trung bình
- 1 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/pprof
-
Make comments more discoverable in the web UICó thể đã có người làm @jabrailkhalil đã nhận 24 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
google/pprof#1029 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
google/pprof#1020 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pprof cannot locate source code for the list command in common Go setupsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
google/pprof#1009 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Label with zero int64 value and no unit get dropped during decodingCó thể đã có người làm @ms-hujia đã nhận 130 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
google/pprof#1002 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
google/pprof#992 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
github/github-mcp-server#3581 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
agent-review-finding chore
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
jordansmall/spindrift#6033 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Replace UUID implementationĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
hyperledger/fabric-x-common#230 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
About.md no longer usedĐang mởbug
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 65/100
open-wanderer/wanderer#1443 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày