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

feat: support record cpu profile #761

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

zhuliquan
Copy link
Contributor

@zhuliquan zhuliquan commented Oct 21, 2024

This PR can help us analyze CPU performance through pprof, I have written a new route /debug/pprof/profile to bind to the original admin HTTP service. We can use the following method to obtain the profile file.

root@arroyo-worker-job-fuybkun7nu-15-0:/app# curl -v http://127.0.0.1:6901/debug/pprof/profile?duration=60 --output profile.pb.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 127.0.0.1:6901...
* Connected to 127.0.0.1 (127.0.0.1) port 6901 (#0)
> GET /debug/pprof/profile?duration=60 HTTP/1.1
> Host: 127.0.0.1:6901
> User-Agent: curl/7.88.1
> Accept: */*
>
  0     0    0     0    0     0      0      0 --:--:--  0:01:03 --:--:--     0< HTTP/1.1 200 OK
< content-type: application/octet-stream
< content-disposition: attachment; filename="profile.pb.gz"
< content-length: 174913
< date: Mon, 21 Oct 2024 07:10:20 GMT
<
{ [43853 bytes data]
100  170k  100  170k    0     0   2726      0  0:01:04  0:01:04 --:--:-- 44987
* Connection #0 to host 127.0.0.1 left intact

Then, you can use below command to visualize profile.pb.gz

go tool pprof -http=:8080 .\profile.pb.gz

image

@zhuliquan zhuliquan force-pushed the feature-pprof_profile branch from a4f4264 to 94dd480 Compare October 21, 2024 08:04
@mwylde mwylde force-pushed the feature-pprof_profile branch from 94dd480 to d83560a Compare October 25, 2024 01:04
Copy link
Member

@mwylde mwylde left a comment

Choose a reason for hiding this comment

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

This is great! Thank you.

@mwylde mwylde enabled auto-merge (squash) October 25, 2024 01:05
@mwylde mwylde merged commit 776965a into ArroyoSystems:master Oct 25, 2024
3 checks passed
@zhuliquan zhuliquan deleted the feature-pprof_profile branch October 25, 2024 14:53
@zhuliquan zhuliquan mentioned this pull request Oct 29, 2024
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.

2 participants