ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
5.82k stars 402 forks source link

why different versions so different in performance? #112

Closed molaifeng closed 1 year ago

molaifeng commented 2 years ago

hi guys,i found performance different in below golang versions

go version go1.13.3 linux/amd64

go-callvis -nostd -format=png -file callvis -group pkg,type github.com/ofabry/go-callvis
2022/03/18 15:10:53 DoAnalysis cost time: 16745542967ns 16745ms 16s
2022/03/18 15:10:54 Render cost time: 455554266ns 455ms 0s
2022/03/18 15:10:54 writing dot output..
2022/03/18 15:10:54 converting dot to png..
2022/03/18 15:10:54 dotToImage cost time: 613374870ns 613ms 0s
2022/03/18 15:10:54 go-callvis cost time: 17815048790ns 17815ms 17s

go version go1.14.15 linux/amd64

go-callvis -nostd -format=png -file callvis -group pkg,type github.com/ofabry/go-callvis
2022/03/18 15:30:33 DoAnalysis cost time: 17452440051ns 17452ms 17s
2022/03/18 15:31:35 Render cost time: 61986208719ns 61986ms 61s
2022/03/18 15:31:35 writing dot output..
2022/03/18 15:31:35 converting dot to png..
2022/03/18 15:31:36 dotToImage cost time: 1147424816ns 1147ms 1s
2022/03/18 15:31:36 go-callvis cost time: 80586575118ns 80586ms 80s

go version go1.15.15 linux/amd64

go-callvis -nostd -format=png -file callvis -group pkg,type github.com/ofabry/go-callvis
2022/03/18 16:48:00 DoAnalysis cost time: 16880622365ns 16880ms 16s
2022/03/18 16:49:05 Render cost time: 64603692398ns 64603ms 64s
2022/03/18 16:49:05 writing dot output..
2022/03/18 16:49:05 converting dot to png..
2022/03/18 16:49:06 dotToImage cost time: 611400279ns 611ms 0s
2022/03/18 16:49:06 go-callvis cost time: 82096326726ns 82096ms 82s

go version go1.16.7 linux/amd64

go-callvis -nostd -format=png -file callvis -group pkg,type github.com/ofabry/go-callvis
2022/03/18 15:13:47 DoAnalysis cost time: 17306170581ns 17306ms 17s
2022/03/18 15:14:58 Render cost time: 70706309840ns 70706ms 70s
2022/03/18 15:14:58 writing dot output..
2022/03/18 15:14:58 converting dot to png..
2022/03/18 15:14:59 dotToImage cost time: 707760094ns 707ms 0s
2022/03/18 15:14:59 go-callvis cost time: 88720752986ns 88720ms 88s

go version go1.17.8 linux/amd64

go-callvis -nostd -format=png -file callvis -group pkg,type github.com/ofabry/go-callvis
2022/03/18 15:22:21 DoAnalysis cost time: 21193581177ns 21193ms 21s
2022/03/18 15:23:39 Render cost time: 77598735968ns 77598ms 77s
2022/03/18 15:23:39 writing dot output..
2022/03/18 15:23:39 converting dot to png..
2022/03/18 15:23:39 dotToImage cost time: 628825900ns 628ms 0s
2022/03/18 15:23:39 go-callvis cost time: 99422245127ns 99422ms 99s

go version go1.18 linux/amd64

it does't work

go-callvis -nostd -format=png -file stock -group pkg,type github.com/ofabry/go-callvis
panic: in crypto/sha256.Sum224: cannot convert slice t0[:] ([]byte) to *[28]byte

goroutine 2729 [running]:
golang.org/x/tools/go/ssa.emitConv(0xc010461b80, {0xb99378, 0xc01a36ab00}, {0xb94e58?, 0xc00a5e4e30})
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/emit.go:242 +0x7c7
golang.org/x/tools/go/ssa.(*builder).expr0(0xa36520?, 0xc010461b80, {0xb95d78?, 0xc00a2d0f40}, {0x7, {0xb94e58, 0xc00a5e4e30}, {0x0, 0x0}})
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:573 +0x925
golang.org/x/tools/go/ssa.(*builder).expr(0xc018d19b38?, 0xc010461b80, {0xb95d78?, 0xc00a2d0f40?})
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:530 +0x19f
golang.org/x/tools/go/ssa.(*builder).assign(0xc010461b80?, 0xc010461b80?, {0xb97060?, 0xc01a33bf50}, {0xb95d78?, 0xc00a2d0f40?}, 0x0?, 0xc016a075d0)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:502 +0x3db
golang.org/x/tools/go/ssa.(*builder).assignStmt(0xa17780?, 0xc010461b80, {0xc00a2ea1c0, 0x1, 0x2?}, {0xc00a2ea1e0, 0x1, 0xc01af006b0?}, 0x1)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:1050 +0x25d
golang.org/x/tools/go/ssa.(*builder).stmt(0x0?, 0xc010461b80, {0xb95bf8?, 0xc00a2d0f80?})
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2009 +0x1094
golang.org/x/tools/go/ssa.(*builder).stmtList(0x0?, 0x7efc883fee60?, {0xc002a4bf80?, 0x7, 0x20?})
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:790 +0x67
golang.org/x/tools/go/ssa.(*builder).stmt(0xc010461b80?, 0xc010461b80, {0xb95d18?, 0xc00a2cdbc0?})
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2105 +0x1331
golang.org/x/tools/go/ssa.(*builder).buildFunction(0xa36820?, 0xc010461b80)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2198 +0x465
golang.org/x/tools/go/ssa.(*builder).buildFuncDecl(0xa36820?, 0xc00995a8a0, 0xc00a2cdbf0)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2228 +0x154
golang.org/x/tools/go/ssa.(*Package).build(0xc00995a8a0)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2344 +0xd05
sync.(*Once).doSlow(0xc000b177b8?, 0x7f3fbe?)
    /usr/local/src/go-1.18/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
    /usr/local/src/go-1.18/src/sync/once.go:59
golang.org/x/tools/go/ssa.(*Package).Build(...)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2263
golang.org/x/tools/go/ssa.(*Program).Build.func1(0x0?)
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2247 +0x4c
created by golang.org/x/tools/go/ssa.(*Program).Build
    /home/molaifeng/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2246 +0x19c

go1.13.3 was the best,i don't know why ?

ondrajz commented 1 year ago

Panic for the go 1.18 is possibly fixed by #121 The version 1.13 probably did not have as much features - so I would expect that running pointer analysis takes much less time.