Skip to content

Instantly share code, notes, and snippets.

@bryanl
Created August 1, 2019 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanl/2f8c06b15523e261403eae7ce8972169 to your computer and use it in GitHub Desktop.
Save bryanl/2f8c06b15523e261403eae7ce8972169 to your computer and use it in GitHub Desktop.
profile.txt
[I] ➜ go tool pprof http://localhost:3001/debug/pprof/heap
Fetching profile over HTTP from http://localhost:3001/debug/pprof/heap
Saved profile in /Users/bryan/pprof/pprof.alloc_objects.alloc_space.inuse_objects.inuse_space.013.pb.gz
Type: inuse_space
Time: Aug 1, 2019 at 3:28pm (EDT)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 676.12MB, 90.43% of 747.64MB total
Dropped 171 nodes (cum <= 3.74MB)
Showing top 10 nodes out of 94
flat flat% sum% cum cum%
361.60MB 48.37% 48.37% 626.46MB 83.79% encoding/json.(*decodeState).objectInterface
212.36MB 28.40% 76.77% 212.36MB 28.40% encoding/json.unquote
35MB 4.68% 81.45% 197.86MB 26.46% encoding/json.(*decodeState).literalInterface
14.50MB 1.94% 83.39% 14.50MB 1.94% reflect.mapassign
11MB 1.47% 84.86% 333.57MB 44.62% encoding/json.(*decodeState).arrayInterface
9.09MB 1.22% 86.08% 9.09MB 1.22% encoding/json.(*RawMessage).UnmarshalJSON
8.54MB 1.14% 87.22% 8.54MB 1.14% bytes.makeSlice
8.50MB 1.14% 88.36% 15.01MB 2.01% k8s.io/client-go/rest.NewRequest
8.50MB 1.14% 89.50% 8.50MB 1.14% runtime.malg
7.01MB 0.94% 90.43% 7.01MB 0.94% k8s.io/apimachinery/pkg/apis/meta/v1/unstructured.setNestedFieldNoCopy
(pprof) list .objectInterface
Total: 747.64MB
ROUTINE ======================== encoding/json.(*decodeState).objectInterface in /usr/local/Cellar/go/1.12.7/libexec/src/encoding/json/decode.go
361.60MB 715.47MB (flat, cum) 95.70% of Total
. . 1061: return v
. . 1062:}
. . 1063:
. . 1064:// objectInterface is like object but returns map[string]interface{}.
. . 1065:func (d *decodeState) objectInterface() map[string]interface{} {
54.50MB 54.50MB 1066: m := make(map[string]interface{})
. . 1067: for {
. . 1068: // Read opening " of string key or closing }.
. . 1069: d.scanWhile(scanSkipSpace)
. . 1070: if d.opcode == scanEndObject {
. . 1071: // closing } - can only happen on first iteration.
. . 1072: break
. . 1073: }
. . 1074: if d.opcode != scanBeginLiteral {
. . 1075: panic(phasePanicMsg)
. . 1076: }
. . 1077:
. . 1078: // Read string key.
. . 1079: start := d.readIndex()
. . 1080: d.scanWhile(scanContinue)
. . 1081: item := d.data[start:d.readIndex()]
. 49.50MB 1082: key, ok := unquote(item)
. . 1083: if !ok {
. . 1084: panic(phasePanicMsg)
. . 1085: }
. . 1086:
. . 1087: // Read : before value.
. . 1088: if d.opcode == scanSkipSpace {
. . 1089: d.scanWhile(scanSkipSpace)
. . 1090: }
. . 1091: if d.opcode != scanObjectKey {
. . 1092: panic(phasePanicMsg)
. . 1093: }
. . 1094: d.scanWhile(scanSkipSpace)
. . 1095:
. . 1096: // Read value.
307.10MB 611.46MB 1097: m[key] = d.valueInterface()
. . 1098:
. . 1099: // Next token must be , or }.
. . 1100: if d.opcode == scanSkipSpace {
. . 1101: d.scanWhile(scanSkipSpace)
. . 1102: }
(pprof)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment