summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-03-17 19:42:33 (GMT)
committerQi Wang <interwq@gmail.com>2017-05-23 19:26:20 (GMT)
commitb693c7868ea965407aca4cb01fdb8fe9af14adce (patch)
tree704dbd12a4ddd24e8336e1547343663b530bbce6 /test/unit
parent3f685e88245c9807d7bdcaffce47b0fe14b974be (diff)
downloadjemalloc-b693c7868ea965407aca4cb01fdb8fe9af14adce.zip
jemalloc-b693c7868ea965407aca4cb01fdb8fe9af14adce.tar.gz
jemalloc-b693c7868ea965407aca4cb01fdb8fe9af14adce.tar.bz2
Implementing opt.background_thread.
Added opt.background_thread to enable background threads, which handles purging currently. When enabled, decay ticks will not trigger purging (which will be left to the background threads). We limit the max number of threads to NCPUs. When percpu arena is enabled, set CPU affinity for the background threads as well. The sleep interval of background threads is dynamic and determined by computing number of pages to purge in the future (based on backlog).
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/decay.c20
-rw-r--r--test/unit/smoothstep.c2
-rw-r--r--test/unit/stats.c6
3 files changed, 25 insertions, 3 deletions
diff --git a/test/unit/decay.c b/test/unit/decay.c
index 19f76fa..f727bf9 100644
--- a/test/unit/decay.c
+++ b/test/unit/decay.c
@@ -10,6 +10,18 @@ static nstime_t time_mock;
static bool monotonic_mock;
static bool
+check_background_thread_enabled(void) {
+ bool enabled;
+ size_t sz = sizeof(bool);
+ int ret = mallctl("background_thread", (void *)&enabled, &sz, NULL,0);
+ if (ret == ENOENT) {
+ return false;
+ }
+ assert_d_eq(ret, 0, "Unexpected mallctl error");
+ return enabled;
+}
+
+static bool
nstime_monotonic_mock(void) {
return monotonic_mock;
}
@@ -167,6 +179,8 @@ generate_dirty(unsigned arena_ind, size_t size) {
}
TEST_BEGIN(test_decay_ticks) {
+ test_skip_if(check_background_thread_enabled());
+
ticker_t *decay_ticker;
unsigned tick0, tick1, arena_ind;
size_t sz, large0;
@@ -405,6 +419,7 @@ decay_ticker_helper(unsigned arena_ind, int flags, bool dirty, ssize_t dt,
}
TEST_BEGIN(test_decay_ticker) {
+ test_skip_if(check_background_thread_enabled());
#define NPS 2048
ssize_t ddt = opt_dirty_decay_ms;
ssize_t mdt = opt_muzzy_decay_ms;
@@ -466,6 +481,7 @@ TEST_BEGIN(test_decay_ticker) {
TEST_END
TEST_BEGIN(test_decay_nonmonotonic) {
+ test_skip_if(check_background_thread_enabled());
#define NPS (SMOOTHSTEP_NSTEPS + 1)
int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
void *ps[NPS];
@@ -523,6 +539,8 @@ TEST_BEGIN(test_decay_nonmonotonic) {
TEST_END
TEST_BEGIN(test_decay_now) {
+ test_skip_if(check_background_thread_enabled());
+
unsigned arena_ind = do_arena_create(0, 0);
assert_zu_eq(get_arena_pdirty(arena_ind), 0, "Unexpected dirty pages");
assert_zu_eq(get_arena_pmuzzy(arena_ind), 0, "Unexpected muzzy pages");
@@ -541,6 +559,8 @@ TEST_BEGIN(test_decay_now) {
TEST_END
TEST_BEGIN(test_decay_never) {
+ test_skip_if(check_background_thread_enabled());
+
unsigned arena_ind = do_arena_create(-1, -1);
int flags = MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE;
assert_zu_eq(get_arena_pdirty(arena_ind), 0, "Unexpected dirty pages");
diff --git a/test/unit/smoothstep.c b/test/unit/smoothstep.c
index 6e3eb0f..549aed1 100644
--- a/test/unit/smoothstep.c
+++ b/test/unit/smoothstep.c
@@ -1,7 +1,7 @@
#include "test/jemalloc_test.h"
static const uint64_t smoothstep_tab[] = {
-#define STEP(step, h, x, y) \
+#define STEP(step, h, x, y, h_sum) \
h,
SMOOTHSTEP
#undef STEP
diff --git a/test/unit/stats.c b/test/unit/stats.c
index f5ee128..d9849d8 100644
--- a/test/unit/stats.c
+++ b/test/unit/stats.c
@@ -115,8 +115,10 @@ TEST_BEGIN(test_stats_arenas_summary) {
"Unexepected mallctl() result");
if (config_stats) {
- assert_u64_gt(dirty_npurge + muzzy_npurge, 0,
- "At least one purge should have occurred");
+ if (!background_thread_enabled()) {
+ assert_u64_gt(dirty_npurge + muzzy_npurge, 0,
+ "At least one purge should have occurred");
+ }
assert_u64_le(dirty_nmadvise, dirty_purged,
"dirty_nmadvise should be no greater than dirty_purged");
assert_u64_le(muzzy_nmadvise, muzzy_purged,