cockroachdb / cockroach

CockroachDB - the open source, cloud-native distributed SQL database.
https://www.cockroachlabs.com
Other
29.51k stars 3.7k forks source link

pprof: quotes in labels break graphviz output #101523

Open tbg opened 1 year ago

tbg commented 1 year ago

Describe the problem

Make sure graphviz is installed. Download this profile, which was taken using the 23.1 test cluster, mv pprof.pb.gz{.txt,}, then go tool pprof -http :6060 pprof.pb.gz. Then try to get the "Graph" view to work; it will instead print

Could not execute dot; may need to install graphviz.

but really the problem is that what pprof feeds to dot is not valid input:

Serving web UI on http://localhost:6060
Error: <stdin>: syntax error in line 43 near '{'
Failed to execute dot. Is Graphviz installed?
exit status 1

pprof.pb.gz.txt

To Reproduce

Output of go tool pprof -dot pprof.pb.gz.txt > pprof.dot is attached: pprof.dot.txt

and this reproduces:

$ dot < pprof.dot.txt
Error: <stdin>: syntax error in line 44 near '{'

That line is the range_str label, which evidently isn't getting escaped properly:

N36_0 [label = "range_str:12419/2:/Table/136/1/"{NHCH-…-PWN-a"}" id="N36_0" fontsize=8 shape=box3d tooltip="0.01s"]

Short term, we should properly escape the range_str label, but really pprof should properly escape the tags, which would be an upstream contribution (which would then take a while to trickle into a Go distribution we'll eventually upgrade to). Arguably this is an upstream bug, will file it as such.

Jira issue: CRDB-26989

tbg commented 1 year ago

Filed https://github.com/google/pprof/issues/769 upstream.

We should quick-fix on our end by avoiding the quotes, though.

cucaroach commented 1 year ago

Hacky work around:

git clone github.com:/cucaroach/pprof
cd pprof
go build -o crpprof

// usage, if you don't want to see pprof labels in svg...
PPROF_OMIT_NODELETS=y crpprof ...