This is an automated email from the ASF dual-hosted git repository.
hulk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/kvrocks-website.git
The following commit(s) were added to refs/heads/main by this push:
new 39a85a7c Add how-to-profile-memory page (#305)
39a85a7c is described below
commit 39a85a7cf8ceb90f0d7254a81e9f81d85c674d66
Author: hulk <[email protected]>
AuthorDate: Fri Jun 6 09:20:16 2025 +0800
Add how-to-profile-memory page (#305)
Co-authored-by: Twice <[email protected]>
---
docs/how-to-profile-memory.md | 39 +++++++++++++++++++++++++++++++++++++++
sidebars.js | 1 +
2 files changed, 40 insertions(+)
diff --git a/docs/how-to-profile-memory.md b/docs/how-to-profile-memory.md
new file mode 100644
index 00000000..a35323d2
--- /dev/null
+++ b/docs/how-to-profile-memory.md
@@ -0,0 +1,39 @@
+# How to profile memory
+
+To make the memory profiling easier, Kvrocks provides the command `KPROFILE`
to active/deactive and dump the memory profiling data. Note that it is only
available while Jemalloc is enabled in the building phase.
+
+## Prerequisites
+
+Before profiling, you need to run Kvrocks server with the following
environment variables:
+
+```bash
+export MALLOC_CONF="prof:true,background_thread:true"
+./kvrocks -c kvrocks.conf
+```
+
+or
+
+```bash
+MALLOC_CONF="prof:true,background_thread:true" ./kvrocks -c kvrocks.conf
+```
+
+Docker users don't need to set this environment variable, as the Dockerfile
already sets it.
+
+## Use KPROFILE command
+
+Once Kvrocks is running with the above environment variable set, you can use
the `KPROFILE` command to control the profiling:
+
+```bash
+# Enable memory profiling
+$ redis-cli> KPROFILE MEMORY ENABLE
+
+# Dump memory profiling data to a file in the specified directory,
+# the profiling filename will be prefixed with `jeprof-`
+$ redis-cli> KPROFILE MEMORY DUMP [dir]
+
+# Disable memory profiling
+$ redis-cli> KPROFILE MEMORY DISABLE
+```
+
+Then you can use the `jeprof` tool to analyze the dumped profiling data. For
more information about `jeprof`, you can refer to the [Jemalloc
documentation](https://github.com/jemalloc/jemalloc/wiki/Use-Case%3A-Heap-Profiling).
+
diff --git a/sidebars.js b/sidebars.js
index 9f7ee9f2..522c5143 100644
--- a/sidebars.js
+++ b/sidebars.js
@@ -15,6 +15,7 @@ const sidebars = {
},
items: [
'backup',
+ 'how-to-profile-memory',
'kvrocks-exporter',
'kvrocks2redis',
]