0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-23 22:27:35 -05:00
zot/pkg/debug/pprof/pprof.md
Andrei Aaron a11fe2d195
feat(pprof): add profiling route handler to debug runtime (#1818)
(cherry picked from commit 56ddb70f624e7070ad0d3531d498675f9f82c664)

Signed-off-by: Alex Stan <alexandrustan96@yahoo.ro>
Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
Co-authored-by: Alex Stan <alexandrustan96@yahoo.ro>
2023-09-18 14:05:41 -07:00

1.2 KiB

Profiling in Zot

This project gives the user the posibility to debug and profile the runtime to find relevant data such as CPU intensive function calls. An in-depth article on profiling in Go can be found here.

A call to http://localhost:8080/v2/_zot/pprof/ would list the following available profiles, wrapped in an HTML file, with count values prior to change due to the runtime:

Types of profiles available:
Count	Profile
95	allocs
0	block
0	cmdline
11	goroutine
95	heap
0	mutex
0	profile
13	threadcreate
0	trace
full goroutine stack dump

For example, the following can be used to gather the cpu profile for the amount of seconds specified as a query parameter, and then the results are stored in cpu.prof file:

curl -sK -v http://localhost:8080/v2/_zot/pprof/profile?seconds=30 > cpu.prof

Then, the user can use the go tool pprof to analyze the information generated previously in cpu.prof. The following command boots up an http server with a GUI and multiple charts that represent the data.

go tool pprof -http=:9090 cpu.prof

A flamegraph example would look like the following: