mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
save decommit_mask for segments in the segment cache
This commit is contained in:
parent
8cc7d0c019
commit
49d64dbc95
5 changed files with 79 additions and 26 deletions
|
@ -35,22 +35,24 @@ static void test_mt_shutdown();
|
|||
static void large_alloc(void); // issue #363
|
||||
static void fail_aslr(); // issue #372
|
||||
static void tsan_numa_test(); // issue #414
|
||||
static void strdup_test(); // issue #445
|
||||
static void strdup_test(); // issue #445
|
||||
static void bench_alloc_large(void); // issue #xxx
|
||||
|
||||
int main() {
|
||||
mi_stats_reset(); // ignore earlier allocations
|
||||
|
||||
heap_thread_free_large();
|
||||
heap_no_delete();
|
||||
heap_late_free();
|
||||
padding_shrink();
|
||||
various_tests();
|
||||
large_alloc();
|
||||
tsan_numa_test();
|
||||
strdup_test();
|
||||
|
||||
heap_thread_free_large();
|
||||
heap_no_delete();
|
||||
heap_late_free();
|
||||
padding_shrink();
|
||||
various_tests();
|
||||
large_alloc();
|
||||
tsan_numa_test();
|
||||
strdup_test();
|
||||
|
||||
//test_mt_shutdown();
|
||||
//fail_aslr();
|
||||
//bench_alloc_large();
|
||||
mi_stats_print(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
@ -246,11 +248,42 @@ static void fail_aslr() {
|
|||
// issues #414
|
||||
static void dummy_worker() {
|
||||
void* p = mi_malloc(0);
|
||||
mi_free(p);
|
||||
mi_free(p);
|
||||
}
|
||||
|
||||
static void tsan_numa_test() {
|
||||
auto t1 = std::thread(dummy_worker);
|
||||
dummy_worker();
|
||||
t1.join();
|
||||
}
|
||||
}
|
||||
|
||||
// issue #?
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
#include <iostream>
|
||||
|
||||
static void bench_alloc_large(void) {
|
||||
static constexpr int kNumBuffers = 20;
|
||||
static constexpr size_t kMinBufferSize = 5 * 1024 * 1024;
|
||||
static constexpr size_t kMaxBufferSize = 25 * 1024 * 1024;
|
||||
std::unique_ptr<char[]> buffers[kNumBuffers];
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(42); //rd());
|
||||
std::uniform_int_distribution<> size_distribution(kMinBufferSize, kMaxBufferSize);
|
||||
std::uniform_int_distribution<> buf_number_distribution(0, kNumBuffers - 1);
|
||||
|
||||
static constexpr int kNumIterations = 2000;
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < kNumIterations; ++i) {
|
||||
int buffer_idx = buf_number_distribution(gen);
|
||||
size_t new_size = size_distribution(gen);
|
||||
buffers[buffer_idx] = std::make_unique<char[]>(new_size);
|
||||
}
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
const auto num_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
const auto us_per_allocation = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / kNumIterations;
|
||||
std::cout << kNumIterations << " allocations Done in " << num_ms << "ms." << std::endl;
|
||||
std::cout << "Avg " << us_per_allocation << " us per allocation" << std::endl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue