Remove prof_threshold built-in event. It is trivial to implement it as user event if needed

This commit is contained in:
Slobodan Predolac 2026-02-12 11:49:28 -08:00 committed by Guangli Dai
parent bee30a9cd3
commit 7bf49ca689
22 changed files with 1 additions and 270 deletions

View file

@ -156,7 +156,6 @@ CTL_PROTO(opt_prof_active)
CTL_PROTO(opt_prof_thread_active_init)
CTL_PROTO(opt_prof_bt_max)
CTL_PROTO(opt_lg_prof_sample)
CTL_PROTO(opt_experimental_lg_prof_threshold)
CTL_PROTO(opt_lg_prof_interval)
CTL_PROTO(opt_prof_gdump)
CTL_PROTO(opt_prof_final)
@ -364,7 +363,6 @@ CTL_PROTO(experimental_hooks_prof_backtrace)
CTL_PROTO(experimental_hooks_prof_dump)
CTL_PROTO(experimental_hooks_prof_sample)
CTL_PROTO(experimental_hooks_prof_sample_free)
CTL_PROTO(experimental_hooks_prof_threshold)
CTL_PROTO(experimental_hooks_thread_event)
CTL_PROTO(experimental_hooks_safety_check_abort)
CTL_PROTO(experimental_thread_activity_callback)
@ -527,8 +525,6 @@ static const ctl_named_node_t opt_node[] = {{NAME("abort"), CTL(opt_abort)},
{NAME("prof_thread_active_init"), CTL(opt_prof_thread_active_init)},
{NAME("prof_bt_max"), CTL(opt_prof_bt_max)},
{NAME("lg_prof_sample"), CTL(opt_lg_prof_sample)},
{NAME("experimental_lg_prof_threshold"),
CTL(opt_experimental_lg_prof_threshold)},
{NAME("lg_prof_interval"), CTL(opt_lg_prof_interval)},
{NAME("prof_gdump"), CTL(opt_prof_gdump)},
{NAME("prof_final"), CTL(opt_prof_final)},
@ -890,7 +886,6 @@ static const ctl_named_node_t experimental_hooks_node[] = {
{NAME("prof_dump"), CTL(experimental_hooks_prof_dump)},
{NAME("prof_sample"), CTL(experimental_hooks_prof_sample)},
{NAME("prof_sample_free"), CTL(experimental_hooks_prof_sample_free)},
{NAME("prof_threshold"), CTL(experimental_hooks_prof_threshold)},
{NAME("safety_check_abort"), CTL(experimental_hooks_safety_check_abort)},
{NAME("thread_event"), CTL(experimental_hooks_thread_event)},
};
@ -2236,8 +2231,6 @@ CTL_RO_NL_CGEN(
config_prof, opt_prof_thread_active_init, opt_prof_thread_active_init, bool)
CTL_RO_NL_CGEN(config_prof, opt_prof_bt_max, opt_prof_bt_max, unsigned)
CTL_RO_NL_CGEN(config_prof, opt_lg_prof_sample, opt_lg_prof_sample, size_t)
CTL_RO_NL_CGEN(config_prof, opt_experimental_lg_prof_threshold,
opt_experimental_lg_prof_threshold, size_t)
CTL_RO_NL_CGEN(config_prof, opt_prof_accum, opt_prof_accum, bool)
CTL_RO_NL_CGEN(
config_prof, opt_prof_pid_namespace, opt_prof_pid_namespace, bool)
@ -3681,29 +3674,6 @@ label_return:
return ret;
}
static int
experimental_hooks_prof_threshold_ctl(tsd_t *tsd, const size_t *mib,
size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) {
int ret;
if (oldp == NULL && newp == NULL) {
ret = EINVAL;
goto label_return;
}
if (oldp != NULL) {
prof_threshold_hook_t old_hook = prof_threshold_hook_get();
READ(old_hook, prof_threshold_hook_t);
}
if (newp != NULL) {
prof_threshold_hook_t new_hook JEMALLOC_CC_SILENCE_INIT(NULL);
WRITE(new_hook, prof_threshold_hook_t);
prof_threshold_hook_set(new_hook);
}
ret = 0;
label_return:
return ret;
}
static int
experimental_hooks_thread_event_ctl(tsd_t *tsd, const size_t *mib,
size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) {

View file

@ -1747,11 +1747,6 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
"lg_prof_sample", 0,
(sizeof(uint64_t) << 3) - 1,
CONF_DONT_CHECK_MIN, CONF_CHECK_MAX, true)
CONF_HANDLE_SIZE_T(
opt_experimental_lg_prof_threshold,
"experimental_lg_prof_threshold", 0,
(sizeof(uint64_t) << 3) - 1,
CONF_DONT_CHECK_MIN, CONF_CHECK_MAX, true)
CONF_HANDLE_BOOL(opt_prof_accum, "prof_accum")
CONF_HANDLE_UNSIGNED(opt_prof_bt_max,
"prof_bt_max", 1, PROF_BT_MAX_LIMIT,

View file

@ -1,69 +0,0 @@
#include "jemalloc/internal/jemalloc_preamble.h"
#include "jemalloc/internal/jemalloc_internal_includes.h"
#include "jemalloc/internal/activity_callback.h"
#include "jemalloc/internal/prof_threshold.h"
#include "jemalloc/internal/prof_externs.h"
/*
* Update every 128MB by default.
*/
#define PROF_THRESHOLD_LG_WAIT_DEFAULT 27
/* Logically a prof_threshold_hook_t. */
static atomic_p_t prof_threshold_hook;
size_t opt_experimental_lg_prof_threshold = PROF_THRESHOLD_LG_WAIT_DEFAULT;
void
prof_threshold_hook_set(prof_threshold_hook_t hook) {
atomic_store_p(&prof_threshold_hook, hook, ATOMIC_RELEASE);
}
prof_threshold_hook_t
prof_threshold_hook_get(void) {
return (prof_threshold_hook_t)atomic_load_p(
&prof_threshold_hook, ATOMIC_ACQUIRE);
}
/* Invoke callback for threshold reached */
static inline void
prof_threshold_update(tsd_t *tsd) {
prof_threshold_hook_t prof_threshold_hook = prof_threshold_hook_get();
if (prof_threshold_hook == NULL) {
return;
}
uint64_t alloc = tsd_thread_allocated_get(tsd);
uint64_t dalloc = tsd_thread_deallocated_get(tsd);
peak_t *peak = tsd_peakp_get(tsd);
pre_reentrancy(tsd, NULL);
prof_threshold_hook(alloc, dalloc, peak->cur_max);
post_reentrancy(tsd);
}
uint64_t
prof_threshold_new_event_wait(tsd_t *tsd) {
return 1 << opt_experimental_lg_prof_threshold;
}
uint64_t
prof_threshold_postponed_event_wait(tsd_t *tsd) {
return TE_MIN_START_WAIT;
}
void
prof_threshold_event_handler(tsd_t *tsd) {
prof_threshold_update(tsd);
}
static te_enabled_t
prof_threshold_enabled(void) {
return config_stats ? te_enabled_yes : te_enabled_no;
}
te_base_cb_t prof_threshold_te_handler = {
.enabled = &prof_threshold_enabled,
.new_event_wait = &prof_threshold_new_event_wait,
.postponed_event_wait = &prof_threshold_postponed_event_wait,
.event_handler = &prof_threshold_event_handler,
};

View file

@ -290,15 +290,6 @@ te_update_alloc_events(tsd_t *tsd, te_base_cb_t **to_trigger,
to_trigger[nto_trigger++] = te_alloc_handlers[te_alloc_peak];
}
assert(te_enabled_yes
== te_alloc_handlers[te_alloc_prof_threshold]->enabled());
if (te_update_wait(tsd, accumbytes, allow,
&waits[te_alloc_prof_threshold], wait,
te_alloc_handlers[te_alloc_prof_threshold],
1 << opt_experimental_lg_prof_threshold)) {
to_trigger[nto_trigger++] =
te_alloc_handlers[te_alloc_prof_threshold];
}
#endif
for (te_alloc_t ue = te_alloc_user0; ue <= te_alloc_user3; ue++) {

View file

@ -6,7 +6,6 @@
#include "jemalloc/internal/tcache_externs.h"
#include "jemalloc/internal/peak_event.h"
#include "jemalloc/internal/prof_externs.h"
#include "jemalloc/internal/prof_threshold.h"
#include "jemalloc/internal/stats.h"
static malloc_mutex_t uevents_mu;
@ -149,7 +148,7 @@ te_base_cb_t *te_alloc_handlers[te_alloc_count] = {
#endif
&stats_interval_te_handler, &tcache_gc_te_handler,
#ifdef JEMALLOC_STATS
&prof_threshold_te_handler, &peak_te_handler,
&peak_te_handler,
#endif
&user_alloc_handler0, &user_alloc_handler1, &user_alloc_handler2,
&user_alloc_handler3};