directory name and module name not same, go tool pprof, list function faild

99 views
Skip to first unread message

blade...@gmail.com

unread,
Jul 30, 2020, 2:09:29 AM7/30/20
to golang-nuts
hi, i create a project, directory name and module name not same, and i profile it , use list command  to print code and profile, it tips me not find the file,  how to make it works?


macbookpro:tejia_analysis fredlee$ go tool pprof http://ip:6065/debug/pprof/heap

Fetching profile over HTTP from http://ip:6065/debug/pprof/heap

Saved profile in /Users/fredlee/pprof/pprof.tejia_analysis.alloc_objects.alloc_space.inuse_objects.inuse_space.006.pb.gz

File: tejia_analysis

Type: inuse_space

Time: Jul 30, 2020 at 2:03pm (CST)

Entering interactive mode (type "help" for commands, "o" for options)

(pprof) top20 -cum

Showing nodes accounting for 2509.12MB, 98.97% of 2535.11MB total

Dropped 37 nodes (cum <= 12.68MB)

      flat  flat%   sum%        cum   cum%

         0     0%     0%  2533.11MB 99.92%  app_server/util.(*Analysis).Job

         0     0%     0%  2533.11MB 99.92%  app_server/util.(*Analysis).Start

 1007.72MB 39.75% 39.75%  2523.10MB 99.53%  app_server/util.(*Analysis).LoadSearchLog

         0     0% 39.75%  1466.37MB 57.84%  go.mongodb.org/mongo-driver/bson.(*Decoder).Decode

         0     0% 39.75%  1466.37MB 57.84%  go.mongodb.org/mongo-driver/bson.UnmarshalWithRegistry

         0     0% 39.75%  1466.37MB 57.84%  go.mongodb.org/mongo-driver/bson.unmarshalFromReader

         0     0% 39.75%  1466.37MB 57.84%  go.mongodb.org/mongo-driver/bson/bsoncodec.(*StructCodec).DecodeValue

         0     0% 39.75%  1466.37MB 57.84%  go.mongodb.org/mongo-driver/mongo.(*Cursor).Decode (inline)

         0     0% 39.75%  1457.37MB 57.49%  go.mongodb.org/mongo-driver/bson/bsoncodec.(*StringCodec).DecodeValue

         0     0% 39.75%  1457.37MB 57.49%  go.mongodb.org/mongo-driver/bson/bsonrw.(*valueReader).ReadString

 1457.37MB 57.49% 97.24%  1457.37MB 57.49%  go.mongodb.org/mongo-driver/bson/bsonrw.(*valueReader).readString

         0     0% 97.24%    44.03MB  1.74%  net/url.ParseQuery (inline)

   44.03MB  1.74% 98.97%    44.03MB  1.74%  net/url.parseQuery

(pprof) list LoadSearchLog

Total: 2.48GB

ROUTINE ======================== app_server/util.(*Analysis).LoadSearchLog in app_server/util/analysis.go

 1007.72MB     2.46GB (flat, cum) 99.53% of Total

 Error: could not find file app_server/util/analysis.go on path /Users/fredlee/Documents/tool/tejia_analysis


Vladimir Varankin

unread,
Jul 31, 2020, 8:00:02 AM7/31/20
to golang-nuts
Hey,

In your example, "~/Documents/tool/tejia_analysis" is your module's source root, right? Could you show where "app_server/util/analysis.go" is on the FS and what is the name of the module?

pprof has a coupe flags to manipulate with the path, helping it to search for the source code. I used to use the combination of "-source_path" and "-trim_path" to map my local source code to the paths that were embedded into the app's binary.

Lee Rick

unread,
Aug 3, 2020, 6:24:28 AM8/3/20
to golang-nuts
se the combination of "-source_path" and "-trim_path"  still not work


my project dir tree

macbookpro:tejia_analysis fredlee$ pwd

/Users/fredlee/Documents/xxx/tool/tejia_analysis

macbookpro:tejia_analysis fredlee$ tree util

util

├── analysis.go

├── configure.go

├── cron.go

├── job_discount.go

├── kv_bolt.go

├── mongo_client.go

├── mongo_globalairport.go

├── mysql_aircompany.go

├── mysql_client.go

├── mysql_convertcode.go

├── mysql_icmmgt_top_route.go

└── redis_client.go


0 directories, 12 files




go mod  name

macbookpro:tejia_analysis fredlee$ cat go.mod 

module app_server


go 1.14



在 2020年7月31日星期五 UTC+8下午8:00:02,Vladimir Varankin写道:
Reply all
Reply to author
Forward
0 new messages