summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2022-01-07 01:46:55 (GMT)
committerQi Wang <interwq@gmail.com>2022-01-07 18:28:28 (GMT)
commit6230cc88b6b3902902c58e4331ca6273e71b8e2e (patch)
tree6483a0c93a3305d6f40d50d4480c7475229926bc
parent61978bbe693c020ffa29dee17b81072ac52726e0 (diff)
downloadjemalloc-6230cc88b6b3902902c58e4331ca6273e71b8e2e.zip
jemalloc-6230cc88b6b3902902c58e4331ca6273e71b8e2e.tar.gz
jemalloc-6230cc88b6b3902902c58e4331ca6273e71b8e2e.tar.bz2
Add background thread sleep retry in test/unit/hpa_background_thread
Under high concurrency / heavy test load (e.g. using run_tests.sh), the background thread may not get scheduled for a longer period of time. Retry 100 times max before bailing out.
-rw-r--r--test/unit/hpa_background_thread.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/unit/hpa_background_thread.c b/test/unit/hpa_background_thread.c
index ad7bac4..81c2561 100644
--- a/test/unit/hpa_background_thread.c
+++ b/test/unit/hpa_background_thread.c
@@ -4,8 +4,8 @@
static void
sleep_for_background_thread_interval() {
/*
- * The sleep interval set in our .sh file is 50ms. So it should
- * definitely run if we sleep for for times that.
+ * The sleep interval set in our .sh file is 50ms. So it likely will
+ * run if we sleep for four times that.
*/
sleep_ns(200 * 1000 * 1000);
}
@@ -117,10 +117,18 @@ expect_purging(unsigned arena_ind, bool expect_deferred) {
}
}
expect_b_eq(expect_deferred, observed_dirty_page, "");
- if (expect_deferred) {
+
+ /*
+ * Under high concurrency / heavy test load (e.g. using run_test.sh),
+ * the background thread may not get scheduled for a longer period of
+ * time. Retry 100 times max before bailing out.
+ */
+ unsigned retry = 0;
+ while ((empty_ndirty = get_empty_ndirty(arena_ind)) > 0 &&
+ expect_deferred && (retry++ < 100)) {
sleep_for_background_thread_interval();
}
- empty_ndirty = get_empty_ndirty(arena_ind);
+
expect_zu_eq(0, empty_ndirty, "Should have seen a background purge");
}