Skip to content
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

docs: add Developer document for Performance Profiling in zot #128

Merged
merged 7 commits into from
Oct 12, 2023

Conversation

mbshields
Copy link
Contributor

@mbshields mbshields commented Sep 26, 2023

What type of PR is this?

documentation

Which issue does this PR fix:

[Feat]: Include a profiling article in the docs
127

What does this PR do / Why do we need it:

explains to developers how to make use of the performance profiling feature in zot

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mbshields mbshields requested a review from rchincha September 26, 2023 22:26

/v2/_zot/pprof/

> :pencil2: You must be authenticated to access `/v2/` API commands.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> :pencil2: You must be authenticated to access `/v2/` API commands.
> :pencil2: If you have authentication enabled, only an admin user can access this API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: "If authentication is enabled, only an admin user can access this API."


!!! note "Documentation comments"

Is this section helpful? Need a more interesting illustration (maybe Flame?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a more typical example, if possible.

@andaaron andaaron linked an issue Sep 27, 2023 that may be closed by this pull request

> :point_right: Use zot's built-in profiling tools to collect and analyze runtime performance.

The profiling capabilities within zot allow a zot administrator to collect and export a range of diagnostic performance data such as CPU intensive function calls, memory allocations, and execution traces. The collected data can then be analyzed using go tools and a variety of available visualization tools.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would add a link from "administrator" to authN/authZ content

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: "...allow a zot administrator to collect..."

@rchincha
Copy link
Contributor

rchincha commented Oct 6, 2023

Put profiling document under "Articles" and cross-ref from admin guide (since admin creds/authZ) and developer guide.


To collect and export any available profile, use the following API command format:

/v2/_zot/pprof/<profile-name>[?<query-parameters>]
Copy link
Contributor

@rchincha rchincha Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<profile-type>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to "Articles" and added cross-ref links from other guides.

/v2/_zot/pprof/

> :pencil2: If authentication is enabled, only an admin user can access this API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supported Profile Types

zot incorporates golang`s pprof package and therefore the following profile types are supported.

profile
heap
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are listed in the previous section "## What data is available?". I added the golang pprof link to that section.


/v2/_zot/pprof/<profile-name>[?<query-parameters>]

The following example shows an API request for the CPU usage profile named `profile` using a collection window of 10 seconds:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... assuming zot is running at localhost:8080

Copy link
Contributor

@rchincha rchincha Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at top of this article ...
unless specified, the examples and code snippets in this article assume zot running at localhost:8080

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added note in the top section: "All examples in this article assume that the zot registry is running at localhost:8080."


The following example shows an API request for the CPU usage profile named `profile` using a collection window of 10 seconds:

$ curl -s -v http://localhost:8080/v2/_zot/pprof/profile?seconds=10 > cpu10.prof
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the -v and all the curl logs below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" > cpu.prof"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made.

{ [107 bytes data]
* Connection #0 to host localhost left intact

This command creates an output data file named "cpu10.prof".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"cpu.prof"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


The pprof package can generate graphic representations of profile data in many formats. This example generates a GIF file representing the CPU usage in the "cpu10.prof" file.

$ go tool pprof -gif cpu10.prof
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"cpu.prof"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


You can collect trace data with the `trace` profile, as in this example:

$ curl -s -v http://localhost:8080/v2/_zot/pprof/trace?seconds=10 > trace10.prof
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"trace.prof"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also standardize "seconds=30"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

mkdocs.yml Outdated
@@ -110,6 +110,7 @@ nav:
- Developer Guide:
- Onboarding: developer-guide/onboarding.md
- Extensions: developer-guide/extensions-dev.md
- Performance Profiling: developer-guide/pprofiling.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this under Articles and xref.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,146 @@
# Performance Profiling in zot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of assets/profile001.gif
Convert this into jpg or png

Rename this file and profiling-001.png

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename assets/images/flame.svg and profiling-flame.svg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mbshields mbshields force-pushed the docs_mishield_pprof branch from d01c51c to 681f687 Compare October 11, 2023 17:56
@@ -52,6 +52,14 @@

- You can adjust the background scheduler based on your deployment requirements for tasks that are handled in the background, such as garbage collection. See [Configuring zot](../admin-guide/admin-configuration.md).

### Performance profiling for troubleshooting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing copied twice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rchincha rchincha merged commit 86ba036 into project-zot:main Oct 12, 2023
4 checks passed
@mbshields mbshields deleted the docs_mishield_pprof branch October 24, 2023 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat]: Include a profiling article in the docs
3 participants