]> Cypherpunks repositories - gostls13.git/commit
runtime/pprof: add streaming protobuf encoder
authorRuss Cox <rsc@golang.org>
Fri, 17 Feb 2017 05:10:39 +0000 (00:10 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 24 Feb 2017 20:15:56 +0000 (20:15 +0000)
commitcbab65fdfa1cf74f65a480de0447388286169f26
tree380e6aebc8e472edc6e27f0815a275958f895e99
parent322fff8ac855390dc2a2876e9051a8dd526d2c6a
runtime/pprof: add streaming protobuf encoder

The existing code builds a full profile in memory.
Then it translates that profile into a data structure (in memory).
Then it marshals that data structure into a protocol buffer (in memory).
Then it gzips that marshaled form into the underlying writer.
So there are three copies of the full profile data in memory
at the same time before we're done. This is obviously dumb.

This CL implements a fully streaming conversion from
the original in-memory profile to the underlying writer.
There is now only one copy of the profile in memory.

For the non-CPU profiles, this is optimal, since we have to
have a full copy in memory to start with.

For the CPU profiles, we could still try to bound the profile
size stored in memory and stream fragments out during
the actual profiling, as Go 1.7 did (with a simpler format),
but so far that hasn't been necessary.

Change-Id: Ic36141021857791bf0cd1fce84178fb5e744b989
Reviewed-on: https://go-review.googlesource.com/37164
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/go/build/deps_test.go
src/runtime/pprof/mprof_test.go
src/runtime/pprof/pprof.go
src/runtime/pprof/pprof_test.go
src/runtime/pprof/proto.go
src/runtime/pprof/proto_test.go
src/runtime/pprof/protobuf.go [new file with mode: 0644]
src/runtime/pprof/protomem.go
src/runtime/pprof/protomem_test.go