Files
greptimedb/src/common/mem-prof
Ruihang Xia 93f21b188d chore: unify workspace dependencies and remove some unused (#2713)
* log-store

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* base64

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* udeps

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* snafu

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* snafu style

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* change the workspace deps' style

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
2023-11-09 07:34:22 +00:00
..
2023-03-07 17:12:51 +08:00

Profile memory usage of GreptimeDB

This crate provides an easy approach to dump memory profiling info.

Prerequisites

jemalloc

# for macOS
brew install jemalloc

# for Ubuntu
sudo apt install libjemalloc-dev

flamegraph

curl https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl > ./flamegraph.pl 

Build GreptimeDB with mem-prof feature.

cargo build --features=mem-prof

Profiling

Start GreptimeDB instance with environment variables:

MALLOC_CONF=prof:true,lg_prof_interval:28 ./target/debug/greptime standalone start

Dump memory profiling data through HTTP API:

curl localhost:4000/v1/prof/mem > greptime.hprof

You can periodically dump profiling data and compare them to find the delta memory usage.

Analyze profiling data with flamegraph

To create flamegraph according to dumped profiling data:

jeprof --svg <path_to_greptimedb_binary> --base=<baseline_prof> <profile_data> > output.svg