mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-27 08:29:59 +00:00
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:
@@ -9,7 +9,7 @@ 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
|
||||
curl -s '0:4000/debug/prof/cpu' > /tmp/pprof.out
|
||||
```
|
||||
|
||||
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.
|
||||
```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.
|
||||
```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
|
||||
```
|
||||
@@ -35,7 +35,7 @@ MALLOC_CONF=prof:true,lg_prof_interval:28 ./target/debug/greptime standalone sta
|
||||
Dump memory profiling data through HTTP API:
|
||||
|
||||
```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.
|
||||
@@ -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:
|
||||
|
||||
```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
|
||||
```
|
||||
@@ -730,6 +730,7 @@ impl HttpServer {
|
||||
authorize::check_http_auth,
|
||||
)),
|
||||
)
|
||||
// Handlers for debug, we don't expect a timeout.
|
||||
.nest(
|
||||
"/debug",
|
||||
Router::new()
|
||||
@@ -737,19 +738,19 @@ impl HttpServer {
|
||||
.route(
|
||||
"/log_level",
|
||||
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(
|
||||
"/mem",
|
||||
routing::get(mem_prof::mem_prof_handler).post(mem_prof::mem_prof_handler),
|
||||
.nest(
|
||||
"/prof",
|
||||
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),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user