Go pprof: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=
* https://go.dev/blog/pprof
* https://pkg.go.dev/net/http/pprof


=Internal=
=Internal=
* [[Go Engineering#Subjects|Go Engineering]]
* [[Go Engineering#Subjects|Go Engineering]]
=Reading List=
<font color=darkkhaki>
Read these and link those wroth it from External:
* https://go.dev/blog/pprof
* https://pkg.go.dev/net/http/pprof
* https://github.com/google/pprof
* https://dave.cheney.net/high-performance-go-workshop/sydney-2019.html
* https://jvns.ca/blog/2017/09/24/profiling-go-with-pprof/
* Official pprof User Manual: https://github.com/google/pprof/blob/main/doc/README.md
</font>


=Overview=
=Overview=
Go comes with built-in frameworks for testing and profiling.
Go comes with built-in frameworks for testing and profiling.
 
=Subjects=
=Concepts=
* [[Go_pprof_Concepts#Overview|Concepts]]
 
* [[Go_pprof_Operations#Overview|Operations]]
==Profile==
 
=Profile a Running Process=
 
Assuming that your local 127.0.0.1 address is aliased to "localhost.somedomain.com" in <code>/etc/hosts</code> and the certificates are issued for "localhost.somedomain.com", set <code>CERT_PATH</code> to the directory that contains <code></code> and <code></code> and:
 
<syntaxhighlight lang='bash'>
export CERT_PATH=/Users/ovidiu/some-project/config
go tool pprof -http 127.0.0.1:8080 -tls_cert ${CERT_PATH}/localhost.somedomain.com.chain.pem -tls_key ${CERT_PATH}/localhost.somedomain.com.key.pem https://localhost.somedomain.com:8443
</syntaxhighlight>
 
=Inspect a Running Process with a Browser=
 
Go to https://localhost.somedomain.com:8443/debug/pprof/
 
=Dump the Goroutines into a Text File=
 
<syntaxhighlight lang='bash'>
curl -k https://localhost:8443/debug/pprof/goroutine?debug=2
</syntaxhighlight>
 
Replace the port with the actual HTTP(S) port the process is listening on.

Latest revision as of 03:30, 16 November 2024