Skip to content

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Jun 2, 2025

This closes #3006.

Currently, it's hard to identify where's occupying the memory when it goes high.
To mitigate this issue, we would like to introduce a profiling command to make the
process easier.

To enable this feature, you need to set the MALLOC_CONF environment variable before running the Kvrocks server, like the following instruction:

$ export MALLOC_CONF="prof:true,background_thread:true"
$ ./kvrocks -c kvrocks.conf

or

MALLOC_CONF="prof:true,background_thread:true" ./kvrocks -c kvrocks.conf

You could also enable the profiling feature without activating the profiling behavior to avoid the overhead:

MALLOC_CONF="prof:true,prof_active:false,background_thread:true" ./kvrocks -c kvrocks.conf

You can then enable it at runtime if necessary:

## Enable the memory profiling, set prof_active to true.
$ redis-cli> KPROFILE MEMORY ENABLE

## Inspect the profiling status
$ redis-cli> KPROFILE MEMORY status

## Dump the profiling file into /tmp directory, which named with `jeprof_` prefix.
$ redis-cli> KPROFILE MEMORY DUMP /tmp

## Disable the memory profiling, set prof_active to false.
$ redis-cli> KPROFILE MEMORY DISABLE

@git-hulk git-hulk force-pushed the feature/memory-profiling-command branch from 3451ceb to eac143b Compare June 2, 2025 14:35
@git-hulk git-hulk force-pushed the feature/memory-profiling-command branch from eac143b to 6ad423b Compare June 2, 2025 14:36
@git-hulk git-hulk force-pushed the feature/memory-profiling-command branch from eb15f28 to 062cf9e Compare June 3, 2025 14:00
@git-hulk git-hulk force-pushed the feature/memory-profiling-command branch from 13d04a5 to 8b17084 Compare June 3, 2025 15:00
@git-hulk git-hulk marked this pull request as ready for review June 4, 2025 01:19
@git-hulk git-hulk changed the title feat(command): add a new command 'PROFILING' to enable/disable/dump the memory profiling feat(command): add a new command to enable/disable/dump the memory profiling Jun 4, 2025
@git-hulk git-hulk requested a review from PragmaTwice June 4, 2025 01:33
@git-hulk git-hulk requested a review from PragmaTwice June 4, 2025 10:57
@git-hulk git-hulk merged commit ed2b6a8 into apache:unstable Jun 4, 2025
36 checks passed
Copy link

sonarqubecloud bot commented Jun 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
41.7% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new command to allow enabling/disabling/dumping the memory heap
2 participants