diff --git a/CMakeLists.txt b/CMakeLists.txt index fe74d3967..acff0bad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,8 +177,25 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY) add_test(${TESTNAME} ${TESTNAME}) endif() if (${TEST_CATEGORY} MATCHES "perf") + message(STATUS "Single threaded test: ${TESTNAME}") set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4) endif() + if(MSVC) + # On Windows these tests use a lot of memory as it doesn't support + # lazy commit. + if (${TEST} MATCHES "two_alloc_types") + message(STATUS "Single threaded test: ${TESTNAME}") + set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4) + endif() + if (${TEST} MATCHES "fixed_region") + message(STATUS "Single threaded test: ${TESTNAME}") + set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4) + endif() + if (${TEST} MATCHES "memory") + message(STATUS "Single threaded test: ${TESTNAME}") + set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4) + endif() + endif() if (${TEST_CATEGORY} MATCHES "func") target_compile_definitions(${TESTNAME} PRIVATE -DUSE_SNMALLOC_STATS) endif () diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2e5963002..37f2d44fb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ trigger: pr: - master - + jobs: - job: displayName: Linux @@ -130,6 +130,12 @@ jobs: JFlag: '-j 2' steps: + - script: | + bash -c "cat /proc/cpuinfo" + bash -c "cat /proc/meminfo" + displayName: 'Machine stats' + + - task: CMake@1 displayName: 'CMake .. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType) -DSNMALLOC_CI_BUILD=On' inputs: diff --git a/src/mem/globalalloc.h b/src/mem/globalalloc.h index 92ade2ca6..2cdb5c414 100644 --- a/src/mem/globalalloc.h +++ b/src/mem/globalalloc.h @@ -170,6 +170,8 @@ namespace snmalloc { error("debug_check_empty: found non-empty allocators"); } +#else + UNUSED(result); #endif } }; diff --git a/src/test/func/memory/memory.cc b/src/test/func/memory/memory.cc index 73f40f57b..389742802 100644 --- a/src/test/func/memory/memory.cc +++ b/src/test/func/memory/memory.cc @@ -1,5 +1,7 @@ +#include #include #include +#include #include #include @@ -215,11 +217,14 @@ void test_external_pointer_large() // Pre allocate all the objects size_t* objects[count]; + size_t total_size = 0; + for (size_t i = 0; i < count; i++) { size_t b = snmalloc::bits::is64() ? 28 : 26; size_t rand = r.next() & ((1 << b) - 1); size_t size = (1 << 24) + rand; + total_size += size; // store object objects[i] = (size_t*)alloc->alloc(size); // Store allocators size for this object @@ -235,6 +240,9 @@ void test_external_pointer_large() check_external_pointer_large(objects[i]); } + std::cout << "Total size allocated in test_external_pointer_large: " + << total_size << std::endl; + // Deallocate everything for (size_t i = 0; i < count; i++) { @@ -290,6 +298,8 @@ void test_calloc_16M() int main(int argc, char** argv) { + setup(); + #ifdef USE_SYSTEMATIC_TESTING opt::Opt opt(argc, argv); size_t seed = opt.is("--seed", 0); diff --git a/src/test/perf/external_pointer/externalpointer.cc b/src/test/perf/external_pointer/externalpointer.cc index d4124b325..f6a8478d4 100644 --- a/src/test/perf/external_pointer/externalpointer.cc +++ b/src/test/perf/external_pointer/externalpointer.cc @@ -54,7 +54,13 @@ namespace test #ifdef NDEBUG static constexpr size_t iterations = 10000000; #else +# ifdef _MSC_VER + // Windows Debug build is very slow on this test. + // Reduce complexity to balance CI times. + static constexpr size_t iterations = 50000; +# else static constexpr size_t iterations = 100000; +# endif #endif setup(r, alloc); diff --git a/src/test/setup.h b/src/test/setup.h index 528d5c0a4..76d523027 100644 --- a/src/test/setup.h +++ b/src/test/setup.h @@ -1,19 +1,95 @@ #if defined(WIN32) && defined(SNMALLOC_CI_BUILD) # include +# include +# include # include # include +// Has to come after the PAL. +# include +# pragma comment(lib, "dbghelp.lib") + +void print_stack_trace() +{ + DWORD error; + HANDLE hProcess = GetCurrentProcess(); + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; + + pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); + pSymbol->MaxNameLen = MAX_SYM_NAME; + + SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); + + if (!SymInitialize(hProcess, NULL, TRUE)) + { + // SymInitialize failed + error = GetLastError(); + printf("SymInitialize returned error : %d\n", error); + return; + } + + void* stack[1024]; + DWORD count = CaptureStackBackTrace(0, 1024, stack, NULL); + IMAGEHLP_LINE64 line; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + + for (int i = 0; count > 0; count--, i++) + { + DWORD64 dwDisplacement = 0; + DWORD64 dwAddress = (DWORD64)stack[i]; + + if (SymFromAddr(hProcess, dwAddress, &dwDisplacement, pSymbol)) + { + DWORD dwDisplacement2 = 0; + if (SymGetLineFromAddr64(hProcess, dwAddress, &dwDisplacement2, &line)) + { + std::cerr << "Frame: " << pSymbol->Name << " (" << line.FileName << ": " + << line.LineNumber << ")" << std::endl; + } + else + { + std::cerr << "Frame: " << pSymbol->Name << std::endl; + } + } + else + { + error = GetLastError(); + std::cerr << "SymFromAddr returned error : " << error << std::endl; + } + } +} + void _cdecl error(int signal) { UNUSED(signal); puts("*****ABORT******"); + + print_stack_trace(); + + _exit(1); +} + +# define CALL_LAST 0 +LONG WINAPI VectoredHandler(struct _EXCEPTION_POINTERS* ExceptionInfo) +{ + UNUSED(ExceptionInfo); + + puts("*****UNHANDLED EXCEPTION******"); + + print_stack_trace(); + _exit(1); } + void setup() { // Disable abort dialog box in CI builds. _set_error_mode(_OUT_TO_STDERR); _set_abort_behavior(0, _WRITE_ABORT_MSG); signal(SIGABRT, error); + + AddVectoredExceptionHandler(CALL_LAST, VectoredHandler); } #else void setup() {}