feat!: move v1/prof API to debug/prof (#4810)

* feat!: move v1/prof to debug/prof

* docs: update readme

* docs: move prof docs to docs dir

* chore: update message

* feat!: remove v1/prof

* docs: update mem prof docs
This commit is contained in:
Yingwen
2024-10-11 12:16:37 +08:00
committed by GitHub
parent 4b34f610aa
commit d168bde226
3 changed files with 24 additions and 20 deletions

View File

@@ -9,7 +9,7 @@ cargo build --features=pprof
## HTTP API ## HTTP API
Sample at 99 Hertz, for 5 seconds, output report in [protobuf format](https://github.com/google/pprof/blob/master/proto/profile.proto). Sample at 99 Hertz, for 5 seconds, output report in [protobuf format](https://github.com/google/pprof/blob/master/proto/profile.proto).
```bash ```bash
curl -s '0:4000/v1/prof/cpu' > /tmp/pprof.out curl -s '0:4000/debug/prof/cpu' > /tmp/pprof.out
``` ```
Then you can use `pprof` command with the protobuf file. Then you can use `pprof` command with the protobuf file.
@@ -19,10 +19,10 @@ go tool pprof -top /tmp/pprof.out
Sample at 99 Hertz, for 60 seconds, output report in flamegraph format. Sample at 99 Hertz, for 60 seconds, output report in flamegraph format.
```bash ```bash
curl -s '0:4000/v1/prof/cpu?seconds=60&output=flamegraph' > /tmp/pprof.svg curl -s '0:4000/debug/prof/cpu?seconds=60&output=flamegraph' > /tmp/pprof.svg
``` ```
Sample at 49 Hertz, for 10 seconds, output report in text format. Sample at 49 Hertz, for 10 seconds, output report in text format.
```bash ```bash
curl -s '0:4000/v1/prof/cpu?seconds=10&frequency=49&output=text' > /tmp/pprof.txt curl -s '0:4000/debug/prof/cpu?seconds=10&frequency=49&output=text' > /tmp/pprof.txt
``` ```

View File

@@ -12,10 +12,10 @@ brew install jemalloc
sudo apt install libjemalloc-dev sudo apt install libjemalloc-dev
``` ```
### [flamegraph](https://github.com/brendangregg/FlameGraph) ### [flamegraph](https://github.com/brendangregg/FlameGraph)
```bash ```bash
curl https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl > ./flamegraph.pl curl https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl > ./flamegraph.pl
``` ```
### Build GreptimeDB with `mem-prof` feature. ### Build GreptimeDB with `mem-prof` feature.
@@ -35,7 +35,7 @@ MALLOC_CONF=prof:true,lg_prof_interval:28 ./target/debug/greptime standalone sta
Dump memory profiling data through HTTP API: Dump memory profiling data through HTTP API:
```bash ```bash
curl localhost:4000/v1/prof/mem > greptime.hprof curl localhost:4000/debug/prof/mem > greptime.hprof
``` ```
You can periodically dump profiling data and compare them to find the delta memory usage. You can periodically dump profiling data and compare them to find the delta memory usage.
@@ -45,6 +45,9 @@ You can periodically dump profiling data and compare them to find the delta memo
To create flamegraph according to dumped profiling data: To create flamegraph according to dumped profiling data:
```bash ```bash
jeprof --svg <path_to_greptimedb_binary> --base=<baseline_prof> <profile_data> > output.svg sudo apt install -y libjemalloc-dev
```
jeprof <path_to_greptime_binary> <profile_data> --collapse | ./flamegraph.pl > mem-prof.svg
jeprof <path_to_greptime_binary> --base <baseline_prof> <profile_data> --collapse | ./flamegraph.pl > output.svg
```

View File

@@ -730,6 +730,7 @@ impl HttpServer {
authorize::check_http_auth, authorize::check_http_auth,
)), )),
) )
// Handlers for debug, we don't expect a timeout.
.nest( .nest(
"/debug", "/debug",
Router::new() Router::new()
@@ -737,19 +738,19 @@ impl HttpServer {
.route( .route(
"/log_level", "/log_level",
routing::get(dyn_log::dyn_log_handler).post(dyn_log::dyn_log_handler), routing::get(dyn_log::dyn_log_handler).post(dyn_log::dyn_log_handler),
),
)
// Handlers for debug, we don't expect a timeout.
.nest(
&format!("/{HTTP_API_VERSION}/prof"),
Router::new()
.route(
"/cpu",
routing::get(pprof::pprof_handler).post(pprof::pprof_handler),
) )
.route( .nest(
"/mem", "/prof",
routing::get(mem_prof::mem_prof_handler).post(mem_prof::mem_prof_handler), Router::new()
.route(
"/cpu",
routing::get(pprof::pprof_handler).post(pprof::pprof_handler),
)
.route(
"/mem",
routing::get(mem_prof::mem_prof_handler)
.post(mem_prof::mem_prof_handler),
),
), ),
) )
} }