-#define IO_MODE_SEQ 0
-#define IO_MODE_RANDOM 1
-
-#define WORKLOAD_TYPE_RO 0
-#define WORKLOAD_TYPE_WO 1
-#define WORKLOAD_TYPE_RW 2
-
-#define MAX_THREADS 1000
-#define MAX_FILENAME 64
-#define MAX_ITERATIONS 10000
-#define LATENCY_BIN_SIZE 500
-#define LATENCY_BINS 11
-#define LOW_LATENCY_BIN_SIZE 50
-#define LOW_LATENCY_BINS 11
+#define IO_MODE_SEQ 0
+#define IO_MODE_RANDOM 1
+
+#define WORKLOAD_TYPE_RO 0
+#define WORKLOAD_TYPE_WO 1
+#define WORKLOAD_TYPE_RW 2
+
+#define MAX_THREADS 1000
+#define MAX_FILENAME 64
+#define MAX_ITERATIONS 10000
+#define LATENCY_BIN_SIZE 500
+#define LATENCY_BINS 11
+#define LOW_LATENCY_BIN_SIZE 50
+#define LOW_LATENCY_BINS 11
-#define DEFAULT_FILE_SIZE (262144)
-#define BLOCKSIZE 1024
-#define MAX_CMD_SIZE 256
-#define PG_MASK ~(0xFFF)
-
-int burst_count = 10; /* Unit: Number ; Desc.: I/O Burst Count */
-int inter_burst_duration = 0; /* Unit: msecs ; Desc.: I/O Inter-Burst Duration (-1: Random value [0,100]) */
-int inter_io_delay_ms = 0; /* Unit: msecs ; Desc.: Inter I/O Delay */
-int thread_count = 1; /* Unit: Number ; Desc.: Thread Count */
+#define DEFAULT_FILE_SIZE (262144)
+#define BLOCKSIZE 1024
+#define MAX_CMD_SIZE 256
+#define PG_MASK ~(0xFFF)
+
+int burst_count = 10; /* Unit: Number ; Desc.: I/O Burst Count */
+int inter_burst_duration = 0; /* Unit: msecs ; Desc.: I/O Inter-Burst Duration (-1: Random value [0,100]) */
+int inter_io_delay_ms = 0; /* Unit: msecs ; Desc.: Inter I/O Delay */
+int thread_count = 1; /* Unit: Number ; Desc.: Thread Count */
-int io_size = 4096; /* Unit: Bytes ; Desc.: I/O Unit Size */
-int sync_frequency_ms = 0; /* Unit: msecs ; Desc.: Sync thread frequency (0: Indicates no sync) */
-int io_mode = 0; /* Unit: 0/1 ; Desc.: I/O Mode (Seq./Rand.) */
+int io_size = 4096; /* Unit: Bytes ; Desc.: I/O Unit Size */
+int sync_frequency_ms = 0; /* Unit: msecs ; Desc.: Sync thread frequency (0: Indicates no sync) */
+int io_mode = 0; /* Unit: 0/1 ; Desc.: I/O Mode (Seq./Rand.) */
-int io_tier = 0; /* Unit: 0/1/2/3; Desc.: I/O Tier */
-int file_size = DEFAULT_FILE_SIZE; /* Unit: pages ; Desc.: File Size in 4096 byte blocks */
-int cached_io_flag = 0; /* Unit: 0/1 ; Desc.: I/O Caching behavior (no-cached/cached) */
-char *user_fname;
+int io_tier = 0; /* Unit: 0/1/2/3; Desc.: I/O Tier */
+int file_size = DEFAULT_FILE_SIZE; /* Unit: pages ; Desc.: File Size in 4096 byte blocks */
+int cached_io_flag = 0; /* Unit: 0/1 ; Desc.: I/O Caching behavior (no-cached/cached) */
+char *user_fname;
void setup_process_io_policy(int io_tier);
void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size);
void setup_process_io_policy(int io_tier);
void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size);
printf("I/O Statistics:\n");
printf("Total I/Os : %lld\n", total_io_count);
printf("I/O Statistics:\n");
printf("Total I/Os : %lld\n", total_io_count);
printf("Low Latency Histogram: \n");
print_latency_histogram(low_latency_histogram, LOW_LATENCY_BINS, LOW_LATENCY_BIN_SIZE);
printf("Low Latency Histogram: \n");
print_latency_histogram(low_latency_histogram, LOW_LATENCY_BINS, LOW_LATENCY_BIN_SIZE);
print_latency_histogram(latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE);
printf("Burst Avg. Latency Histogram: \n");
print_latency_histogram(burst_latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE);
print_latency_histogram(latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE);
printf("Burst Avg. Latency Histogram: \n");
print_latency_histogram(burst_latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE);
ret = read(fd, buf, size);
else
ret = write(fd, buf, size);
ret = read(fd, buf, size);
else
ret = write(fd, buf, size);
if (ret == 0) {
if (lseek(fd, 0, SEEK_SET) < 0) {
perror("lseek() to reset file offset to zero failed!\n");
goto error;
}
}
if (ret == 0) {
if (lseek(fd, 0, SEEK_SET) < 0) {
perror("lseek() to reset file offset to zero failed!\n");
goto error;
}
}
size = total_io_size - prev_total_io_size;
throughput_histogram[throughput_index] = size;
prev_total_io_size = total_io_size;
size = total_io_size - prev_total_io_size;
throughput_histogram[throughput_index] = size;
prev_total_io_size = total_io_size;
if (fstat(fd, &filestat) < 0) {
printf("Error stat()ing file %s!\n", test_filename);
exit(1);
if (fstat(fd, &filestat) < 0) {
printf("Error stat()ing file %s!\n", test_filename);
exit(1);
if (filestat.st_size < io_size) {
printf("%s: File size (%lld) smaller than I/O size (%d)!\n", test_filename, filestat.st_size, io_size);
if (filestat.st_size < io_size) {
printf("%s: File size (%lld) smaller than I/O size (%d)!\n", test_filename, filestat.st_size, io_size);
if(!(data = (char *)calloc(io_size, 1))) {
perror("Error allocating buffers for I/O!\n");
exit(1);
if(!(data = (char *)calloc(io_size, 1))) {
perror("Error allocating buffers for I/O!\n");
exit(1);
gettimeofday(&start_tv, NULL);
perform_io(fd, data, io_size, workload_type);
gettimeofday(&start_tv, NULL);
perform_io(fd, data, io_size, workload_type);
OSAtomicIncrement64(&(latency_histogram[find_io_bin(elapsed, LATENCY_BIN_SIZE, LATENCY_BINS)]));
OSAtomicIncrement64(&(low_latency_histogram[find_io_bin(elapsed, LOW_LATENCY_BIN_SIZE, LOW_LATENCY_BINS)]));
burst_elapsed += elapsed;
OSAtomicIncrement64(&(latency_histogram[find_io_bin(elapsed, LATENCY_BIN_SIZE, LATENCY_BINS)]));
OSAtomicIncrement64(&(low_latency_histogram[find_io_bin(elapsed, LOW_LATENCY_BIN_SIZE, LOW_LATENCY_BINS)]));
burst_elapsed += elapsed;
case 'z':
file_size = atoi(optarg);
validate_option(file_size, 0, INT_MAX, "File Size", "bytes");
case 'z':
file_size = atoi(optarg);
validate_option(file_size, 0, INT_MAX, "File Size", "bytes");
print_test_setup(io_tier, "I/O Tier", "", 0);
print_test_setup(cached_io_flag, "I/O Caching", "", "0 indicates non-cached I/Os");
print_test_setup(0, "File read-aheads", "", "0 indicates read-aheads disabled");
print_test_setup(io_tier, "I/O Tier", "", 0);
print_test_setup(cached_io_flag, "I/O Caching", "", "0 indicates non-cached I/Os");
print_test_setup(0, "File read-aheads", "", "0 indicates read-aheads disabled");
printf("**********************************************************\n");
if (user_specified_file == 0) {
char dd_command[MAX_CMD_SIZE];
for (i=0; i < thread_count; i++) {
snprintf(fname, MAX_FILENAME, "iosim-%d-%d", (int)getpid(), i);
printf("**********************************************************\n");
if (user_specified_file == 0) {
char dd_command[MAX_CMD_SIZE];
for (i=0; i < thread_count; i++) {
snprintf(fname, MAX_FILENAME, "iosim-%d-%d", (int)getpid(), i);
- snprintf(dd_command, MAX_CMD_SIZE, "dd if=/dev/urandom of=%s bs=4096 count=%d", fname, file_size);
+ snprintf(dd_command, MAX_CMD_SIZE, "dd if=/dev/urandom of=%s bs=4096 count=%d", fname, file_size);
- printf("**********************************************************\n");
- printf("Creating threads and generating workload...\n");
+ printf("**********************************************************\n");
+ printf("Creating threads and generating workload...\n");
signal(SIGINT, signalHandler);
signal(SIGALRM, signalHandler);
signal(SIGINT, signalHandler);
signal(SIGALRM, signalHandler);
for(i=0; i < thread_count; i++)
pthread_join(thread_list[i], NULL);
for(i=0; i < thread_count; i++)
pthread_join(thread_list[i], NULL);
if (sync_frequency_ms)
pthread_join(sync_thread, NULL);
pthread_join(throughput_thread, NULL);
pthread_exit(0);
if (sync_frequency_ms)
pthread_join(sync_thread, NULL);
pthread_join(throughput_thread, NULL);
pthread_exit(0);