-
Notifications
You must be signed in to change notification settings - Fork 562
build(jemalloc): enable the profiling option when compiling the jemalloc #3001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(jemalloc): enable the profiling option when compiling the jemalloc #3001
Conversation
This only enables the profiling at the compile stage, but the profiling is not active since we set `prof_active` to false, so it won't bring any overhead for now. We can enable the profiling by setting the environment MALLOC_CONF.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables the jemalloc profiling option at compile time while keeping profiling inactive by default, allowing future activation without performance overhead.
- Introduces a CMake flag that conditionally adds the profiling option.
- Adjusts the configure command to include the profiling flag when profiling is enabled.
cmake/jemalloc.cmake
Outdated
set(ENABLE_JEMALLOC_PROFILING "--enable-prof") | ||
# jemalloc profiling is enabled by default, but we can disable it and | ||
# enable it at runtime by setting the environment variable. | ||
set(JEMALLOC_CONFIG_MALLOC_CONF "prof:true,prof_active:false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a CMake variable and will not be passed to the build phase of jemalloc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh? I see Jemalloc's configure.ac recognizes this environment, so I would like to test if CMake could pass this.
https://github.com/jemalloc/jemalloc/blob/edaab8b3ad752a845019985062689551cd6315c1/configure.ac#L1278
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it can also be configured in runtime via MALLOC_CONF
env var, so we can ignore it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line mainly uses to set prof_active to false by default, so that it won’t collect the profiling unless user sets the MALLOC_CONF to enable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested on my side, the heap profiling won't run if we didn't enable opt.prof=true
via MALLOC_CONF, so we can remove this line.
|
Is there any performance impact of this flag? e.g. through redis-benchmark. |
In summary, there's no impact on performance. Many other projects are also enabled when compiling, like ClickHouse and MySQL(Percona), The first one is running without enable the
The second one is running with
The last one is running with
|
This closes #3000.
This only enables profiling at the compile stage, but since we set
prof_active
to false, the profiling is not active, so it won't incur any overhead for now. We can enable the profiling by setting the environment MALLOC_CONF like:And it will produce the jemalloc under the
/tmp
directory like the following: