コード例 #1
0
// currently, this method checks if there if a file already exists, and if so, assumes it is valid.
// ideally, a check should be made to ensure the saved SSD state matches with the state of the current global parameters
void Experiment::calibrate_and_save(Workload_Definition* workload, string name, int num_IOs, bool force) {
	//string file_name = base_folder + "calibrated_state.txt";
	string file_name = base_folder + name;
	std::ifstream ifile(file_name.c_str());
	if (ifile && !force) {
		return; // file exists
	}
	StatisticsGatherer::set_record_statistics(false);
	//StatisticsGatherer::get_global_instance()->init();
	Thread::set_record_internal_statistics(false);
	VisualTracer::init();
	//Free_Space_Meter::init();
	//Free_Space_Per_LUN_Meter::init();
	printf("Creating calibrated SSD state.\n");
	OperatingSystem* os = new OperatingSystem();
	os->set_num_writes_to_stop_after(num_IOs);
	vector<Thread*> init_threads = workload->generate_instance();
	os->set_threads(init_threads);
	os->set_progress_meter_granularity(1000);

	os->run();
	os->get_ssd()->execute_all_remaining_events();
	save_state(os, file_name);
	//StatisticsGatherer::get_global_instance()->print();
	//Free_Space_Meter::print();
	//Free_Space_Per_LUN_Meter::print();
	delete os;
}
コード例 #2
0
void Experiment::run_single_point(string name) {
	string data_folder = base_folder + name + "/";
	mkdir(data_folder.c_str(), 0755);
	StatisticsGatherer::set_record_statistics(true);
	Thread::set_record_internal_statistics(true);
	Experiment_Result global_result(name, data_folder, "Global/", "");
	Individual_Threads_Statistics::init();
	global_result.start_experiment();
	Free_Space_Meter::init();
	Free_Space_Per_LUN_Meter::init();

	if (generate_trace_file) {
		VisualTracer::init(data_folder);
	} else {
		VisualTracer::init();
	}

	write_config_file(data_folder);
	Queue_Length_Statistics::init();

	OperatingSystem* os = calibration_file.empty() ? new OperatingSystem() : load_state(calibration_file);
	os->set_progress_meter_granularity(20);
	if (workload != NULL) {
		vector<Thread*> experiment_threads = workload->generate_instance();
		os->set_threads(experiment_threads);
	}
	os->set_num_writes_to_stop_after(io_limit);
	os->run();

	StatisticsGatherer::get_global_instance()->print();
	StatisticsGatherer::get_global_instance()->print_mapping_info();
	//StatisticsGatherer::get_global_instance()->print_gc_info();
	Utilization_Meter::print();
	//Individual_Threads_Statistics::print();
	//Queue_Length_Statistics::print_distribution();
	//Queue_Length_Statistics::print_avg();
	Free_Space_Meter::print();
	Free_Space_Per_LUN_Meter::print();

	global_result.collect_stats(0, StatisticsGatherer::get_global_instance());
	write_results_file(data_folder);
	if (!alternate_location_for_results_file.compare("") == 0) {
		printf("writing results in %s\n", alternate_location_for_results_file.c_str());
		write_results_file(alternate_location_for_results_file);
	}

	global_result.end_experiment();
	vector<Experiment_Result> result;
	result.push_back(global_result);
	results.push_back(result);
	delete os;
}