mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 06:59:32 +03:00
update stress test with more documentation
This commit is contained in:
parent
24b768363e
commit
0d3c195f37
1 changed files with 12 additions and 7 deletions
|
@ -5,9 +5,14 @@ terms of the MIT license.
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* This is a stress test for the allocator, using multiple threads and
|
/* This is a stress test for the allocator, using multiple threads and
|
||||||
transferring objects between threads. This is not a typical workload
|
transferring objects between threads. It tries to reflect real-world workloads:
|
||||||
but uses a random linear size distribution. Timing can also depend on
|
- allocation size is distributed linearly in powers of two
|
||||||
(random) thread scheduling. Do not use this test as a benchmark!
|
- with some fraction extra large (and some extra extra large)
|
||||||
|
- the allocations are initialized and read again at free
|
||||||
|
- pointers transfer between threads
|
||||||
|
- threads are terminated and recreated with some objects surviving in between
|
||||||
|
- uses deterministic "randomness", but execution can still depend on
|
||||||
|
(random) thread scheduling. Do not use this test as a benchmark!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -22,13 +27,13 @@ terms of the MIT license.
|
||||||
// argument defaults
|
// argument defaults
|
||||||
static int THREADS = 32; // more repeatable if THREADS <= #processors
|
static int THREADS = 32; // more repeatable if THREADS <= #processors
|
||||||
static int SCALE = 50; // scaling factor
|
static int SCALE = 50; // scaling factor
|
||||||
static int ITER = 10; // N full iterations re-creating all threads
|
static int ITER = 10; // N full iterations destructing and re-creating all threads
|
||||||
|
|
||||||
// static int THREADS = 8; // more repeatable if THREADS <= #processors
|
// static int THREADS = 8; // more repeatable if THREADS <= #processors
|
||||||
// static int SCALE = 100; // scaling factor
|
// static int SCALE = 100; // scaling factor
|
||||||
|
|
||||||
static bool allow_large_objects = true; // allow very large objects?
|
static bool allow_large_objects = true; // allow very large objects?
|
||||||
static size_t use_one_size = 0; // use single object size of N uintptr_t?
|
static size_t use_one_size = 0; // use single object size of `N * sizeof(uintptr_t)`?
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_STD_MALLOC
|
#ifdef USE_STD_MALLOC
|
||||||
|
@ -185,7 +190,7 @@ int main(int argc, char** argv) {
|
||||||
long n = (strtol(argv[3], &end, 10));
|
long n = (strtol(argv[3], &end, 10));
|
||||||
if (n > 0) ITER = n;
|
if (n > 0) ITER = n;
|
||||||
}
|
}
|
||||||
printf("start with %d threads with a %d%% load-per-thread and %d iterations\n", THREADS, SCALE, ITER);
|
printf("Using %d threads with a %d%% load-per-thread and %d iterations\n", THREADS, SCALE, ITER);
|
||||||
//int res = mi_reserve_huge_os_pages(4,1);
|
//int res = mi_reserve_huge_os_pages(4,1);
|
||||||
//printf("(reserve huge: %i\n)", res);
|
//printf("(reserve huge: %i\n)", res);
|
||||||
|
|
||||||
|
@ -204,7 +209,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
mi_collect(false);
|
mi_collect(false);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if ((n + 1) % 10 == 0) { printf("- iterations: %3d\n", n + 1); }
|
if ((n + 1) % 10 == 0) { printf("- iterations left: %3d\n", ITER - n + 1); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue