mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 06:31:43 +03:00
Remove prof_threshold built-in event. It is trivial to implement it as user event if needed
This commit is contained in:
parent
4d0ffa075b
commit
34ace9169b
22 changed files with 1 additions and 270 deletions
|
|
@ -145,7 +145,6 @@ C_SRCS := $(srcroot)src/jemalloc.c \
|
|||
$(srcroot)src/prof_stack_range.c \
|
||||
$(srcroot)src/prof_stats.c \
|
||||
$(srcroot)src/prof_sys.c \
|
||||
$(srcroot)src/prof_threshold.c \
|
||||
$(srcroot)src/psset.c \
|
||||
$(srcroot)src/rtree.c \
|
||||
$(srcroot)src/safety_check.c \
|
||||
|
|
@ -271,8 +270,6 @@ TESTS_UNIT := \
|
|||
$(srcroot)test/unit/prof_stats.c \
|
||||
$(srcroot)test/unit/prof_tctx.c \
|
||||
$(srcroot)test/unit/prof_thread_name.c \
|
||||
$(srcroot)test/unit/prof_threshold.c \
|
||||
$(srcroot)test/unit/prof_threshold_small.c \
|
||||
$(srcroot)test/unit/prof_sys_thread_name.c \
|
||||
$(srcroot)test/unit/psset.c \
|
||||
$(srcroot)test/unit/ql.c \
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ extern bool opt_prof_active;
|
|||
extern bool opt_prof_thread_active_init;
|
||||
extern unsigned opt_prof_bt_max;
|
||||
extern size_t opt_lg_prof_sample; /* Mean bytes between samples. */
|
||||
extern size_t
|
||||
opt_experimental_lg_prof_threshold; /* Mean bytes between thresholds. */
|
||||
extern ssize_t opt_lg_prof_interval; /* lg(prof_interval). */
|
||||
extern bool opt_prof_gdump; /* High-water memory dumping. */
|
||||
extern bool opt_prof_final; /* Final profile dumping. */
|
||||
|
|
@ -70,9 +68,6 @@ prof_sample_hook_t prof_sample_hook_get(void);
|
|||
void prof_sample_free_hook_set(prof_sample_free_hook_t hook);
|
||||
prof_sample_free_hook_t prof_sample_free_hook_get(void);
|
||||
|
||||
void prof_threshold_hook_set(prof_threshold_hook_t hook);
|
||||
prof_threshold_hook_t prof_threshold_hook_get(void);
|
||||
|
||||
/* Functions only accessed in prof_inlines.h */
|
||||
prof_tdata_t *prof_tdata_init(tsd_t *tsd);
|
||||
prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,4 @@ typedef void (*prof_sample_hook_t)(const void *ptr, size_t size,
|
|||
/* ptr, size */
|
||||
typedef void (*prof_sample_free_hook_t)(const void *, size_t);
|
||||
|
||||
/*
|
||||
* A callback hook that notifies when an allocation threshold has been crossed.
|
||||
*/
|
||||
typedef void (*prof_threshold_hook_t)(
|
||||
uint64_t alloc, uint64_t dealloc, uint64_t peak);
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_PROF_HOOK_H */
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef JEMALLOC_INTERNAL_THRESHOLD_EVENT_H
|
||||
#define JEMALLOC_INTERNAL_THRESHOLD_EVENT_H
|
||||
|
||||
#include "jemalloc/internal/tsd_types.h"
|
||||
|
||||
extern te_base_cb_t prof_threshold_te_handler;
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_THRESHOLD_EVENT_H */
|
||||
|
|
@ -14,7 +14,6 @@ enum te_alloc_e {
|
|||
te_alloc_stats_interval,
|
||||
te_alloc_tcache_gc,
|
||||
#ifdef JEMALLOC_STATS
|
||||
te_alloc_prof_threshold,
|
||||
te_alloc_peak,
|
||||
#endif
|
||||
te_alloc_user0,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_recent.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_stats.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_sys.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c" />
|
||||
<ClCompile Include="..\..\..\..\src\psset.c" />
|
||||
<ClCompile Include="..\..\..\..\src\rtree.c" />
|
||||
<ClCompile Include="..\..\..\..\src\safety_check.c" />
|
||||
|
|
|
|||
|
|
@ -133,9 +133,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_sys.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\psset.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_recent.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_stats.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_sys.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c" />
|
||||
<ClCompile Include="..\..\..\..\src\psset.c" />
|
||||
<ClCompile Include="..\..\..\..\src\rtree.c" />
|
||||
<ClCompile Include="..\..\..\..\src\safety_check.c" />
|
||||
|
|
|
|||
|
|
@ -133,9 +133,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_sys.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\psset.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_recent.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_stats.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_sys.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c" />
|
||||
<ClCompile Include="..\..\..\..\src\psset.c" />
|
||||
<ClCompile Include="..\..\..\..\src\rtree.c" />
|
||||
<ClCompile Include="..\..\..\..\src\safety_check.c" />
|
||||
|
|
|
|||
|
|
@ -133,9 +133,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_sys.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\psset.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_recent.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_stats.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_sys.c" />
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c" />
|
||||
<ClCompile Include="..\..\..\..\src\psset.c" />
|
||||
<ClCompile Include="..\..\..\..\src\rtree.c" />
|
||||
<ClCompile Include="..\..\..\..\src\safety_check.c" />
|
||||
|
|
|
|||
|
|
@ -133,9 +133,6 @@
|
|||
<ClCompile Include="..\..\..\..\src\prof_sys.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\prof_threshold.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\psset.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
30
src/ctl.c
30
src/ctl.c
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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++) {
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -342,7 +342,6 @@ TEST_BEGIN(test_mallctl_opt) {
|
|||
TEST_MALLCTL_OPT(bool, prof_active, prof);
|
||||
TEST_MALLCTL_OPT(unsigned, prof_bt_max, prof);
|
||||
TEST_MALLCTL_OPT(ssize_t, lg_prof_sample, prof);
|
||||
TEST_MALLCTL_OPT(ssize_t, experimental_lg_prof_threshold, prof);
|
||||
TEST_MALLCTL_OPT(bool, prof_accum, prof);
|
||||
TEST_MALLCTL_OPT(bool, prof_pid_namespace, prof);
|
||||
TEST_MALLCTL_OPT(ssize_t, lg_prof_interval, prof);
|
||||
|
|
|
|||
|
|
@ -1,112 +0,0 @@
|
|||
#include "test/jemalloc_test.h"
|
||||
|
||||
/* Test config (set in reset_test_config) */
|
||||
#define ALLOC_ITERATIONS_IN_THRESHOLD 10
|
||||
uint64_t threshold_bytes = 0;
|
||||
uint64_t chunk_size = 0;
|
||||
|
||||
/* Test globals for calblack */
|
||||
uint64_t hook_calls = 0;
|
||||
uint64_t last_peak = 0;
|
||||
uint64_t last_alloc = 0;
|
||||
uint64_t alloc_baseline = 0;
|
||||
|
||||
void
|
||||
mock_prof_threshold_hook(uint64_t alloc, uint64_t dealloc, uint64_t peak) {
|
||||
hook_calls++;
|
||||
last_peak = peak;
|
||||
last_alloc = alloc;
|
||||
}
|
||||
|
||||
/* Need the do_write flag because NULL is a valid to_write value. */
|
||||
static void
|
||||
read_write_prof_threshold_hook(prof_threshold_hook_t *to_read, bool do_write,
|
||||
prof_threshold_hook_t to_write) {
|
||||
size_t hook_sz = sizeof(prof_threshold_hook_t);
|
||||
expect_d_eq(
|
||||
mallctl("experimental.hooks.prof_threshold", (void *)to_read,
|
||||
&hook_sz, do_write ? &to_write : NULL, hook_sz),
|
||||
0, "Unexpected prof_threshold_hook mallctl failure");
|
||||
}
|
||||
|
||||
static void
|
||||
write_prof_threshold_hook(prof_threshold_hook_t new_hook) {
|
||||
read_write_prof_threshold_hook(NULL, true, new_hook);
|
||||
}
|
||||
|
||||
static prof_threshold_hook_t
|
||||
read_prof_threshold_hook() {
|
||||
prof_threshold_hook_t hook;
|
||||
read_write_prof_threshold_hook(&hook, false, NULL);
|
||||
return hook;
|
||||
}
|
||||
|
||||
static void
|
||||
reset_test_config() {
|
||||
hook_calls = 0;
|
||||
last_peak = 0;
|
||||
alloc_baseline = last_alloc; /* We run the test multiple times */
|
||||
last_alloc = 0;
|
||||
threshold_bytes = 1 << opt_experimental_lg_prof_threshold;
|
||||
chunk_size = threshold_bytes / ALLOC_ITERATIONS_IN_THRESHOLD;
|
||||
}
|
||||
|
||||
static void
|
||||
expect_threshold_calls(int calls) {
|
||||
expect_u64_eq(
|
||||
hook_calls, calls, "Hook called the right amount of times");
|
||||
expect_u64_lt(
|
||||
last_peak, chunk_size * 2, "We allocate chunk_size at a time");
|
||||
expect_u64_ge(
|
||||
last_alloc, threshold_bytes * calls + alloc_baseline, "Crosses");
|
||||
}
|
||||
|
||||
static void
|
||||
allocate_chunks(int chunks) {
|
||||
for (int i = 0; i < chunks; i++) {
|
||||
void *p = mallocx((size_t)chunk_size, 0);
|
||||
expect_ptr_not_null(p, "Failed to allocate");
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prof_threshold_hook) {
|
||||
test_skip_if(!config_stats);
|
||||
|
||||
/* Test setting and reading the hook (both value and null) */
|
||||
write_prof_threshold_hook(mock_prof_threshold_hook);
|
||||
expect_ptr_eq(read_prof_threshold_hook(), mock_prof_threshold_hook,
|
||||
"Unexpected hook");
|
||||
|
||||
write_prof_threshold_hook(NULL);
|
||||
expect_ptr_null(read_prof_threshold_hook(), "Hook was erased");
|
||||
|
||||
/* Reset everything before the test */
|
||||
reset_test_config();
|
||||
write_prof_threshold_hook(mock_prof_threshold_hook);
|
||||
|
||||
int err = mallctl("thread.peak.reset", NULL, NULL, NULL, 0);
|
||||
expect_d_eq(err, 0, "Peak reset failed");
|
||||
|
||||
/* Note that since we run this test multiple times and we don't reset
|
||||
the allocation counter, each time we offset the callback by the
|
||||
amount we allocate over the threshold. */
|
||||
|
||||
/* A simple small allocation is not enough to trigger the callback */
|
||||
allocate_chunks(1);
|
||||
expect_u64_eq(hook_calls, 0, "Hook not called yet");
|
||||
|
||||
/* Enough allocations to trigger the callback */
|
||||
allocate_chunks(ALLOC_ITERATIONS_IN_THRESHOLD);
|
||||
expect_threshold_calls(1);
|
||||
|
||||
/* Enough allocations to trigger the callback again */
|
||||
allocate_chunks(ALLOC_ITERATIONS_IN_THRESHOLD);
|
||||
expect_threshold_calls(2);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void) {
|
||||
return test(test_prof_threshold_hook);
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#include "test/jemalloc_test.h"
|
||||
#include "prof_threshold.c"
|
||||
|
|
@ -1 +0,0 @@
|
|||
export MALLOC_CONF="experimental_lg_prof_threshold:22"
|
||||
Loading…
Add table
Add a link
Reference in a new issue