-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add HTTP API for cpu profiling (#1694)
* chore: print source error in mem-prof * feat(common-pprof): add pprof crate * feat(servers): Add pprof handler to router refactor the mem_prof handler to avoid checking feature while registering router * feat(servers): pprof handler support different output type * docs(common-pprof): Add readme * feat(common-pprof): Build guard using code in pprof-rs's example * feat(common-pprof): use prost * feat: don't add timeout to perf api * feat: add feature pprof * feat: update readme * test: fix tests * feat: close region in TestBase * feat(pprof): addres comments
- Loading branch information
Showing
12 changed files
with
467 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "common-pprof" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
common-error = { path = "../error" } | ||
pprof = { version = "0.11", features = [ | ||
"flamegraph", | ||
"prost-codec", | ||
"protobuf", | ||
] } | ||
prost.workspace = true | ||
snafu.workspace = true | ||
tokio.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Profiling CPU | ||
|
||
## Build GreptimeDB with `pprof` feature | ||
|
||
```bash | ||
cargo build --features=pprof | ||
``` | ||
|
||
## HTTP API | ||
Sample at 99 Hertz, for 5 seconds, output report in [protobuf format](https://github.com/google/pprof/blob/master/proto/profile.proto). | ||
```bash | ||
curl -s '0:4000/v1/prof/cpu' > /tmp/pprof.out | ||
``` | ||
|
||
Then you can use `pprof` command with the protobuf file. | ||
```bash | ||
go tool pprof -top /tmp/pprof.out | ||
``` | ||
|
||
Sample at 99 Hertz, for 60 seconds, output report in flamegraph format. | ||
```bash | ||
curl -s '0:4000/v1/prof/cpu?seconds=60&output=flamegraph' > /tmp/pprof.svg | ||
``` | ||
|
||
Sample at 49 Hertz, for 10 seconds, output report in text format. | ||
```bash | ||
curl -s '0:4000/v1/prof/cpu?seconds=10&frequency=49&output=text' > /tmp/pprof.txt | ||
``` |
Oops, something went wrong.