ArroyoSystems / arroyo

Distributed stream processing engine in Rust
https://arroyo.dev
Apache License 2.0
3.8k stars 220 forks source link

feat: support record cpu profile #761

Closed zhuliquan closed 4 weeks ago

zhuliquan commented 1 month ago

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