-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime/pprof: generate profiles in gzipped proto format #16093
Comments
I agree the runtime should generate profile.proto directly. I would further propose to deprecate the legacy pprof formats. For pprof to retrieve profiles in profile.proto format, the |
I definitely agree that the runtime should generate profiles in the protocol buffer format. However, I don't think you need to add a new API: just replace the legacy format with the protobuf format. My understanding is that that was the idea from the start with the protobuf format. I believe @rsc even prototyped part of the runtime support just to make sure we weren't backing ourselves into a corner. |
Oh, that's even better! |
I'm interested in the switch to the new format too and could participate in it, I don't want to duplicate efforts, so, could you tell, is any job done? |
@DarKol13 I haven't started any work yet. Feel free to contribute. Is there any part in particular you're interested in? |
@matloob How can I contact you to discuss it in real-time? |
Send me an email off thread to (github username) @golang.org and we can
|
What are your plans for how the information included in the profiles will change?
|
@rhysh We will not drop any of the information currently included in the profile. We're going to start off using some code we've open-sourced from Google that converts from the legacy format to the proto format. You can take a look at in patch set 1 of golang.org/cl/28349. See package internal/protopprof.
|
You're going to put gzip very low in the dependency chain, which doesn't strike me as a good idea. Can you do this without gzip? |
Or perhaps just the gzip part could most to net/http/pprof where it is most useful. |
Yes, we can! pprof understands the ungzipped profiles. I just talked to @rauls5382 who had the same idea as @ianlancetaylor: runtime/pprof returns uncompressed protos, and the http handler gzips it. |
I'd like to see how much code this involves. The proto seems non-trivial, and so the encoder is likely non-trivial too, but I'm prepared to be pleasantly surprised. |
It would be nice to split this into two separate proposals: 1) switching to protobuf format. 2) gzipping the result. |
@adg Most of the code for working with the proto is already in the go tree. For example the core of the encoder code is here: https://golang.org/src/cmd/internal/pprof/profile/proto.go @robpike Renaming this proposal now. It'll now just be (1). |
CL https://golang.org/cl/30556 mentions this issue. |
On-disk pprof profiles are defined to be gzipped, never ungzipped. We were very clear about this when we wrote the spec for them. If pprof accepts ungzipped, that's arguably a bug in pprof. Go should only ever generate the gzipped form. That said, I don't think putting a gzip dependency in runtime/pprof is too big a problem: runtime/pprof (the package you import to actually get the profiles out of the runtime) is not a low-level package. I would be concerned if runtime itself grew a gzip dependency, but runtime/pprof is OK. |
Sounds like the proposal was accepted earlier in the thread; just adding the label to reflect that. |
CL https://golang.org/cl/32257 mentions this issue. |
Original Change by Daria Kolistratova <daria.kolistratova@intel.com> Added functions with suffix proto and stuff from pprof tool to translate to protobuf. Done as the profile proto is more extensible than the legacy pprof format and is pprof's preferred profile format. Large part was taken from https://github.com/google/pprof tool. Tested by hand and compared the result with translated by pprof tool, profiles are identical. Fixes #16093 Change-Id: I2751345b09a66ee2b6aa64be76cba4cd1c326aa6 Reviewed-on: https://go-review.googlesource.com/32257 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
CL https://golang.org/cl/32353 mentions this issue. |
CL https://golang.org/cl/32811 mentions this issue. |
This change adds code, originally written by Russ Cox <rsc@golang.org> and open-sourced by Google, that converts from the "legacy" binary pprof profile format to a struct representation of the new protocol buffer pprof profile format. This code reads the entire binary format for conversion to the protobuf format. In a future change, we will update the code to incrementally read and convert segments of the binary format, so that the entire profile does not need to be stored in memory. This change also contains contributions by Daria Kolistratova <daria.kolistratova@intel.com> from the rolled-back change golang.org/cl/30556 adapting the code to be used by the package runtime/pprof. This code also appeared in the change golang.org/cl/32257, which was based on Daria Kolistratova's change, but was also rolled back. Updates #16093 Change-Id: I5c768b1134bc15408d80a3ccc7ed867db9a1c63d Reviewed-on: https://go-review.googlesource.com/32811 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
CL https://golang.org/cl/33071 mentions this issue. |
CL https://golang.org/cl/33422 mentions this issue. |
When debug is 0, emit the compressed proto format. The debug>0 format stays the same. Updates #16093 Change-Id: I45aa1874a22d34cf44dd4aa78bbff9302381cb34 Reviewed-on: https://go-review.googlesource.com/33422 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
[edit (3 Oct 2016) we now propose to just return the profiles in the serialized proto format. The proposal previously also gzipped the proto]
I propose to add a function
func runtime/pprof.StartCPUProfileProto(w io.Writer) error
and support in the runtime, for generating profiles in serialized profile protocol buffers, rather than in the legacy pprof format.
The profile proto is more extensible than the legacy pprof format and is pprof's preferred profile format. The extensibility will be useful to support generating profiles with labels. pprof supports rendering labeled profiles, but labels can only appear in the proto profile, not in the legacy format.
The profile proto format is already understood by pprof itself and pprof already includes an encoder for producing serialized profile protos without requiring a dependency on the proto package or library.
Here's the pprof proto description: https://github.com/google/pprof/blob/master/proto/profile.proto
and here's the encoder: https://github.com/google/pprof/blob/master/profile/proto.go
For more about labels, take a look at the https://github.com/google/pprof/blob/master/doc/developer/profile.proto.md#labels
The text was updated successfully, but these errors were encountered: