std::vector<iteration_result> StressIncreaseToMax::execute_test_iterations( const TaskConf& task_conf, unsigned time, size_t requested_memory_limit) { TimerSysTime timer; unsigned itr = 0; std::vector<iteration_result> results; std::ofstream csv_file; csv::Row row; row.append("Iteration"); row.append("Allocated memory (MB)"); row.append("Elapsed time (seconds)"); if(task_conf.is_csv_log_enabled) { csv_file.open("stress_test_increase_to_max.csv"); csv_file << row.export_row(); } printf("%s", row.export_row().c_str()); timer.start(); while (timer.getElapsedTime() < time) { StressIncreaseToMax stress_test(task_conf, requested_memory_limit); stress_test.run(); float elapsed_time = timer.getElapsedTime(); TimeStats stats; stats += stress_test.get_results(); results.push_back(stress_test.get_test_status()); //Log every interation of StressIncreaseToMax test. csv::Row row; row.append(itr); row.append(convert_bytes_to_mb(stats.get_allocated())); row.append(elapsed_time); if(task_conf.is_csv_log_enabled) { csv_file << row.export_row(); } printf("%s", row.export_row().c_str()); fflush(stdout); itr++; } printf("\nStress test (StressIncreaseToMax) finish in time %f.\n",timer.getElapsedTime()); csv_file.close(); return results; }
void run() { unsigned mem_operations_num = 10; size_t threads_number = 50; bool touch_memory = true; size_t size_1MB = 1024*1024; size_t alignment = 2*size_1MB; size_t alloc_size = 4*size_1MB; std::vector<Thread*> threads; std::vector<Task*> tasks; TimerSysTime timer; timer.start(); // This bug occurs more frequently under stress of multithreaded allocations. for (int i=0; i<threads_number; i++) { Task* task = new HugePageUnmap(mem_operations_num, touch_memory, alignment, alloc_size, HBW_PAGESIZE_2MB); tasks.push_back(task); threads.push_back(new Thread(task)); } float elapsed_time = timer.getElapsedTime(); ThreadsManager threads_manager(threads); threads_manager.start(); threads_manager.barrier(); threads_manager.release(); //task release for (int i=0; i<tasks.size(); i++) { delete tasks[i]; } RecordProperty("threads_number", threads_number); RecordProperty("memory_operations_per_thread", mem_operations_num); RecordProperty("elapsed_time", elapsed_time); }