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

Introduce ability to get profile data #1215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bcrochet
Copy link
Contributor

This exposes two environment variables, PFLT_MEMPROFILE and PFLT_CPUPROFILE, that should be set to the path and name of a file to write the profile data to. These can then be processed with go tool pprof for further analysis.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2024
@coveralls
Copy link

coveralls commented Nov 20, 2024

Coverage Status

coverage: 84.119% (-0.3%) from 84.446%
when pulling aa27bd4 on bcrochet:profile
into 0184783 on redhat-openshift-ecosystem:main.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 20, 2024
Copy link

openshift-ci bot commented Nov 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bcrochet, skattoju

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dcibot
Copy link

dcibot commented Nov 20, 2024

defer f.Close()

if err := pprof.StartCPUProfile(f); err != nil {
logger.Error(err, "could not start CPU profile")
Copy link
Contributor

Choose a reason for hiding this comment

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

should this error be returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll add that.

if viper.Instance().IsSet("memprofile") {
f, err := os.Create(viper.Instance().GetString("memprofile"))
if err != nil {
logger.Error(err, "could not create memory profile")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this error be returned?


rt.GC() // get up-to-date statistics
if err := pprof.Lookup("allocs").WriteTo(f, 0); err != nil {
logger.Error(err, "could not start memory profile")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this error be returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor

@komish komish left a comment

Choose a reason for hiding this comment

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

Any particular reason why this is only being added to CheckContainer?

@bcrochet
Copy link
Contributor Author

Any particular reason why this is only being added to CheckContainer?

It was where I knew we were looking for a data from. If we decide we need it elsewhere in the future, we can cross that bridge then.

This exposes two environment variables, PFLT_MEMPROFILE and
PFLT_CPUPROFILE, that should be set to the path and name of a file to
write the profile data to. These can then be processed with `go tool
pprof` for further analysis.

Signed-off-by: Brad P. Crochet <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 26, 2024
Copy link

openshift-ci bot commented Nov 26, 2024

New changes are detected. LGTM label has been removed.

@dcibot
Copy link

dcibot commented Nov 26, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants