Skip to contentSkip to conversation

package/jemalloc: add option to enable heap profiling

PATCH New Gleb Stepanov 1 participant 1 message Nov 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/jemalloc: add option to enable heap profiling

jemalloc's heap profiling is disabled by default and must be enabled at build time with --enable-prof. This patch adds BR2_PACKAGE_JEMALLOC_PROF enabling the feature.

To collect allocation backtraces, jemalloc 5.3 picks the first available backend in the following order:
1. libunwind unw_backtrace() (disabled by default)
2. libgcc _Unwind_Backtrace() (enabled by default)
3. gcc intrinsics walking frame pointers (enabled by default)

libunwind has to be requested explicitly with --enable-prof-libunwind. It is typically faster than _Unwind_Backtrace(), which is designed for rare C++ exception unwinding, while libunwind caches unwind information. Add BR2_PACKAGE_JEMALLOC_PROF_LIBUNWIND to use it, which is available when libunwind is enabled and defaults to y.

---
 package/jemalloc/Config.in   | 18 ++++++++++++++++++
 package/jemalloc/jemalloc.mk | 12 ++++++++++++
 2 files changed, 30 insertions(+)
package/jemalloc/Config.in +18 -0
index ace3dccd1e..217ebbbad0 100644
@@ -24,6 +24,24 @@ config BR2_PACKAGE_JEMALLOC
 
 	  http://jemalloc.net/
 
+if BR2_PACKAGE_JEMALLOC
+
+config BR2_PACKAGE_JEMALLOC_PROF
+	bool "enable heap profiling"
+	help
+	  Enable allocation profiling support (--enable-prof).
+
+config BR2_PACKAGE_JEMALLOC_PROF_LIBUNWIND
+	bool "use libunwind for backtracing"
+	default y
+	depends on BR2_PACKAGE_JEMALLOC_PROF
+	depends on BR2_PACKAGE_LIBUNWIND
+	help
+	  Make libunwind the preferred method for collecting
+	  allocation backtraces.
+
+endif
+
 comment "jemalloc needs a toolchain w/ threads"
 	depends on BR2_PACKAGE_JEMALLOC_ARCH_SUPPORTS
 	depends on BR2_USE_MMU
package/jemalloc/jemalloc.mk +12 -0
index 8ac661b9d5..bc77380524 100644
@@ -24,5 +24,17 @@ endif
 
 JEMALLOC_CONF_ENV += CFLAGS="$(JEMALLOC_CFLAGS)"
 
+ifeq ($(BR2_PACKAGE_JEMALLOC_PROF),y)
+JEMALLOC_CONF_OPTS += --enable-prof
+ifeq ($(BR2_PACKAGE_JEMALLOC_PROF_LIBUNWIND),y)
+JEMALLOC_CONF_OPTS += --enable-prof-libunwind
+JEMALLOC_DEPENDENCIES += libunwind
+else
+JEMALLOC_CONF_OPTS += --disable-prof-libunwind
+endif
+else
+JEMALLOC_CONF_OPTS += --disable-prof
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
Signature · 6 lines
2.56.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot