aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-03-17 12:42:33 -0700
committerQi Wang <interwq@gmail.com>2017-05-23 12:26:20 -0700
commitb693c7868ea965407aca4cb01fdb8fe9af14adce (patch)
tree704dbd12a4ddd24e8336e1547343663b530bbce6 /test
parent3f685e88245c9807d7bdcaffce47b0fe14b974be (diff)
downloadplatform_external_jemalloc_new-b693c7868ea965407aca4cb01fdb8fe9af14adce.tar.gz
platform_external_jemalloc_new-b693c7868ea965407aca4cb01fdb8fe9af14adce.tar.bz2
platform_external_jemalloc_new-b693c7868ea965407aca4cb01fdb8fe9af14adce.zip
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')
-rw-r--r--test/integration/extent.c14
-rw-r--r--test/unit/decay.c20
-rw-r--r--test/unit/smoothstep.c2
-rw-r--r--test/unit/stats.c6
4 files changed, 39 insertions, 3 deletions
diff --git a/test/integration/extent.c b/test/integration/extent.c
index 32432af9..7262b803 100644
--- a/test/integration/extent.c
+++ b/test/integration/extent.c
@@ -2,6 +2,18 @@
#include "test/extent_hooks.h"
+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 void
test_extent_body(unsigned arena_ind) {
void *p;
@@ -124,6 +136,7 @@ TEST_BEGIN(test_extent_manual_hook) {
assert_ptr_ne(old_hooks->merge, extent_merge_hook,
"Unexpected extent_hooks error");
+ test_skip_if(check_background_thread_enabled());
test_extent_body(arena_ind);
/* Restore extent hooks. */
@@ -164,6 +177,7 @@ TEST_BEGIN(test_extent_auto_hook) {
assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz,
(void *)&new_hooks, new_size), 0, "Unexpected mallctl() failure");
+ test_skip_if(check_background_thread_enabled());
test_extent_body(arena_ind);
}
TEST_END
diff --git a/test/unit/decay.c b/test/unit/decay.c
index 19f76fa5..f727bf93 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 6e3eb0f9..549aed12 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 f5ee1287..d9849d80 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,