MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / TEST_BEGIN

Function TEST_BEGIN

deps/jemalloc/test/unit/decay.c:487–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485#undef NPS
486}
487TEST_END
488
489TEST_BEGIN(test_decay_nonmonotonic) {
490 test_skip_if(check_background_thread_enabled());
491#define NPS (SMOOTHSTEP_NSTEPS + 1)
492 int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
493 void *ps[NPS];
494 uint64_t npurge0 = 0;
495 uint64_t npurge1 = 0;
496 size_t sz, large0;
497 unsigned i, nupdates0;
498
499 sz = sizeof(size_t);
500 assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL,
501 0), 0, "Unexpected mallctl failure");
502
503 assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
504 "Unexpected mallctl failure");
505 do_epoch();
506 sz = sizeof(uint64_t);
507 npurge0 = get_arena_npurge(0);
508
509 nupdates_mock = 0;
510 nstime_init(&time_mock, 0);
511 nstime_update(&time_mock);
512 monotonic_mock = false;
513
514 nstime_monotonic_orig = nstime_monotonic;
515 nstime_update_orig = nstime_update;
516 nstime_monotonic = nstime_monotonic_mock;
517 nstime_update = nstime_update_mock;
518
519 for (i = 0; i < NPS; i++) {
520 ps[i] = mallocx(large0, flags);
521 assert_ptr_not_null(ps[i], "Unexpected mallocx() failure");
522 }
523
524 for (i = 0; i < NPS; i++) {
525 dallocx(ps[i], flags);
526 nupdates0 = nupdates_mock;
527 assert_d_eq(mallctl("arena.0.decay", NULL, NULL, NULL, 0), 0,
528 "Unexpected arena.0.decay failure");
529 assert_u_gt(nupdates_mock, nupdates0,
530 "Expected nstime_update() to be called");
531 }
532
533 do_epoch();
534 sz = sizeof(uint64_t);
535 npurge1 = get_arena_npurge(0);
536
537 if (config_stats) {
538 assert_u64_eq(npurge0, npurge1, "Unexpected purging occurred");
539 }
540
541 nstime_monotonic = nstime_monotonic_orig;
542 nstime_update = nstime_update_orig;
543#undef NPS
544}

Callers

nothing calls this directly

Calls 11

get_arena_dirty_purgedFunction · 0.85
do_epochFunction · 0.70
get_arena_npurgeFunction · 0.70
do_arena_createFunction · 0.70
get_arena_pdirtyFunction · 0.70
get_arena_pmuzzyFunction · 0.70
generate_dirtyFunction · 0.70
do_arena_destroyFunction · 0.70
do_mallocxFunction · 0.70
nstime_initFunction · 0.50

Tested by

no test coverage detected