Skip to content

Commit

Permalink
TEST/UCM: Fix performance test of malloc with multiple ptrs
Browse files Browse the repository at this point in the history
+ Trim the heap before allocating to force mmap(). Otherwise baseline
  allocation is too fast and the test fails.
+ Disable dynamic mmap threshold to get consistent performance
  measurements.
  • Loading branch information
yosefe committed Feb 12, 2018
1 parent 4a2bc4e commit e813fa0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/gtest/ucm/malloc_hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ UCS_TEST_F(malloc_hook_cplusplus, mmap_ptrs) {
UCS_TEST_SKIP_R("skipping on valgrind");
}

ucm_global_config.enable_dynamic_mmap_thresh = 0;
set();

const size_t size = ucm_dlmallopt_get(M_MMAP_THRESHOLD) * 2;
Expand All @@ -605,16 +606,21 @@ UCS_TEST_F(malloc_hook_cplusplus, mmap_ptrs) {
++large_blocks;
}

/* Remove memory off the heap top, to ensure the following large allocations
* will use mmap()
*/
malloc_trim(0);

/* Measure allocation time with "clear" heap state */
double alloc_time = measure_alloc_time(size, iters);
UCS_TEST_MESSAGE << "With " << large_blocks << " large blocks:"
<< " allocated " << iters << " buffers of " << size
<< " bytes in " << alloc_time << " sec";

/* Allocate many large strings to trigger mmap() based allocation. */
ptrs.resize(count);
for (unsigned i = 0; i < count; ++i) {
std::vector<char> str(size, 't');
ptrs.push_back(str);
ptrs[i].resize(size, 't');
++large_blocks;
}

Expand Down

0 comments on commit e813fa0

Please sign in to comment.