ContainerTracer  0.1
trace_replay.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Block I/O Trace Replayer
3  * Yongseok Oh (ysoh@uos.ac.kr) 2013 - 2014
4 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; under version 2 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ****************************************************************************/
17 
18 #ifndef _TRACE_REPLAY_H
19 #define _TRACE_REPLAY_H
20 
21 #include <stdio.h>
22 #include <libaio.h>
23 #include <flist.h>
24 
25 #define USE_MAINWORKER 0
26 
27 #define LINUX 0
28 #define TEST_OS (LINUX)
29 
30 #define KB (1024)
31 #define MB (1024 * 1024)
32 #define GB (1024 * 1024 * 1024)
33 #define MAX_QDEPTH (128 * 16)
34 #define MAX_THREADS 512
35 #define STR_SIZE 128
36 
37 #ifndef PAGE_SIZE
38 #define PAGE_SIZE 4096
39 #endif
40 #define SECTOR_SIZE 512
41 #define SPP (PAGE_SIZE / SECTOR_SIZE)
42 #define MAX_BYTES (1024 * 1024 * 1024)
43 
44 #define PAGE_TO_MB(x) (x * PAGE_SIZE / MB)
45 
46 struct io_stat_t {
47  pthread_spinlock_t stat_lock;
48  double latency_sum;
50  double latency_min;
51  double latency_max;
52  unsigned int latency_count;
53  unsigned long long total_operations;
54  unsigned long long total_bytes;
55  unsigned long long total_rbytes;
56  unsigned long long total_wbytes;
57  unsigned long long cur_bytes;
58  unsigned long long cur_rbytes;
59  unsigned long long cur_wbytes;
60  unsigned long long total_error_bytes;
61  struct timeval start_time, end_time;
64  double time_diff;
65  unsigned int time_diff_cnt;
66 };
67 
68 struct trace_io_req {
69 #if 0
70  char line[201];
71 #else
72  double arrival_time;
73  int devno;
74  int blkno;
75  int bcount;
76  int flags;
77 #endif
78 };
79 
80 struct trace_info_t {
81  pthread_spinlock_t trace_lock;
82  FILE *trace_fp;
88  char tracename[STR_SIZE];
89  char filename[STR_SIZE];
90  int fd;
91  int synthetic;
92  long long wanted_io_count;
93  int utilization; // % Percent
94  int working_set_size; // in MB
95  int working_set_pages; // in pages
96  int io_size; // in bytes
97  int io_pages; // in pages
98 
103 
106  long long total_capacity;
107  long long total_pages;
108  long long total_sectors;
109  long long start_partition;
110  long long start_page;
112  double timeout;
113 };
114 
116  int tid;
117 
118  // struct flist_head queue;
119  pthread_mutex_t mutex;
120  pthread_cond_t cond_main, cond_sub;
121  io_context_t io_ctx;
122  struct io_event events[MAX_QDEPTH];
123 
127  int fd;
129 
130  struct io_job *th_jobs[MAX_QDEPTH];
131  void *th_buf[MAX_QDEPTH];
132  int buf_cur;
133 
134  struct io_stat_t io_stat;
135 
137 
138  int done;
139 };
140 
141 struct io_job {
142  struct iocb iocb;
143  struct flist_head list;
144  struct timeval start_time, stop_time;
145  long long offset; // in bytes
146  size_t bytes;
147  int rw; // is read
148  char *buf;
149 };
150 
151 #define BASE_KEY_PATHNAME_LEN PATH_MAX
152 #define MSGQ_KEY_PATHNAME "/tmp/trace_replay_msgq"
153 #define SHM_KEY_PATHNAME "/tmp/trace_replay_shm"
154 #define SEM_KEY_PATHNAME "/tmp/trace_replay_sem"
155 #define PROJECT_ID 'M'
156 #define PROJECT_PERM 0640
157 
159 
160 struct realtime_log {
161  int type;
162  double time;
163  double remaining;
165  double avg_bw;
166  double cur_bw;
167  double lat;
168  double time_diff;
169 };
170 
171 struct realtime_msg {
172  long mtype;
173  struct realtime_log log;
174 };
175 
176 struct trace {
177  double start_partition; // in GB
178  double total_size; // in GB
179  long long start_page;
180  long long total_pages;
181 };
182 
183 struct config {
184  int qdepth;
185  double timeout;
186  int nr_trace;
189  char result_file[201];
191 };
192 
193 struct synthetic {
194  int working_set_size; // in MB
195  int utilization; // % Percent
197  int io_size; // in KB
198 };
199 
200 struct trace_stat {
201  double exec_time;
202  double avg_lat;
203  double avg_lat_var;
204  double lat_min;
205  double lat_max;
206  double iops;
207  double total_bw; // MB/s
208  double read_bw; // MB/s
209  double write_bw; // MB/s
210  double total_traffic; // in MB
211  double read_traffic; // in MB
212  double write_traffic; // in MB
213  double read_ratio; // % Percent
214  double total_avg_req_size; // in KB
215  double read_avg_req_size; // in KB
216  double write_avg_req_size; // in KB
217 };
218 
219 struct trace_result {
220  char name[STR_SIZE];
221 
224 
225  struct trace_stat stats;
226 
228 };
229 
230 struct aggr_result {
231  struct trace_stat stats;
232 };
233 
234 struct result {
235  struct trace_result per_trace[MAX_THREADS];
237 };
238 
240  struct config config;
241  struct result results;
242 };
243 
244 #ifndef _ASM_GENERIC_INT_LL64_H // This for the Redhat Linux
245 #ifndef __s8
246 typedef char __s8;
247 #endif
248 typedef short __s16;
249 typedef int __s32;
250 
251 #if TEST_OS == LINUX
252 typedef long long __s64;
253 #endif
254 
255 typedef unsigned char __u8;
256 typedef unsigned short __u16;
257 typedef unsigned int __u32;
258 
259 #if TEST_OS == LINUX
260 typedef unsigned long long __u64;
261 #endif
262 #define _ASM_GENERIC_INT_LL64_H // This for the Redhat Linux
263 #endif
264 long long get_total_bytes(int nr_trace, int nr_thread);
265 void synthetic_mix(struct trace_info_t *trace);
266 
267 #endif
Definition: trace_replay.h:46
int tid
Definition: trace_replay.h:116
double write_bw
Definition: trace_replay.h:209
Definition: trace_replay.h:234
int type
Definition: trace_replay.h:161
pthread_mutex_t mutex
Definition: trace_replay.h:119
double execution_time
Definition: trace_replay.h:62
double avg_lat
Definition: trace_replay.h:202
double total_traffic
Definition: trace_replay.h:210
int trace_buf_size
Definition: trace_replay.h:83
double remaining_percentage
Definition: trace_replay.h:164
Definition: trace_replay.h:183
double write_avg_req_size
Definition: trace_replay.h:216
int per_thread
Definition: trace_replay.h:188
long long start_partition
Definition: trace_replay.h:109
int working_set_size
Definition: trace_replay.h:194
double latency_sum_sqr
Definition: trace_replay.h:49
int nr_thread
Definition: trace_replay.c:56
unsigned long long total_error_bytes
Definition: trace_replay.h:60
Definition: trace_replay.h:68
unsigned long long total_operations
Definition: trace_replay.h:53
FILE * trace_fp
Definition: trace_replay.h:82
Definition: trace_replay.h:171
int trace_io_issue_count
Definition: trace_replay.h:87
Definition: trace_replay.h:158
Definition: trace_replay.h:230
int fd
Definition: trace_replay.h:127
int qdepth
Definition: trace_replay.h:184
long long total_pages
Definition: trace_replay.h:180
double timeout
Definition: trace_replay.h:112
Definition: flist.h:29
double timeout
Definition: trace_replay.h:185
int trace_repeat_count
Definition: trace_replay.h:63
int nr_trace
Definition: trace_replay.h:186
unsigned long long total_wbytes
Definition: trace_replay.h:56
long long total_capacity
Definition: trace_replay.h:106
long long get_total_bytes(int nr_trace, int nr_thread)
double read_avg_req_size
Definition: trace_replay.h:215
int bcount
Definition: trace_replay.h:75
double trace_timescale
Definition: trace_replay.h:111
int devno
Definition: trace_replay.h:73
int trace_io_cur
Definition: trace_replay.h:86
int io_pages
Definition: trace_replay.h:97
double read_traffic
Definition: trace_replay.h:211
long long total_pages
Definition: trace_replay.h:107
double read_bw
Definition: trace_replay.h:208
Definition: trace_replay.h:219
int trace_repeat_count
Definition: trace_replay.h:104
unsigned long long cur_rbytes
Definition: trace_replay.h:58
double iops
Definition: trace_replay.h:206
Definition: trace_replay.h:158
name
Definition: setup.py:13
long long start_page
Definition: trace_replay.h:179
Definition: trace_replay.h:158
double time_diff
Definition: trace_replay.h:168
int trace_repeat_num
Definition: trace_replay.h:105
unsigned long long total_bytes
Definition: trace_replay.h:54
Definition: trace_replay.h:193
double exec_time
Definition: trace_replay.h:201
Definition: trace_replay.h:239
int utilization
Definition: trace_replay.h:93
char * buf
Definition: trace_replay.h:148
struct trace_info_t * trace
Definition: trace_replay.h:136
struct timeval start_time end_time
Definition: trace_replay.h:61
Definition: trace_replay.h:115
int working_set_pages
Definition: trace_replay.h:95
int __s32
Definition: trace_replay.h:249
int synth_mixed
Definition: trace_replay.h:102
double latency_min
Definition: trace_replay.h:50
Definition: trace_replay.h:141
long long total_sectors
Definition: trace_replay.h:108
int synth_write
Definition: trace_replay.h:101
double remaining
Definition: trace_replay.h:163
double write_traffic
Definition: trace_replay.h:212
int rw
Definition: trace_replay.h:147
Definition: trace_replay.h:200
double latency_sum
Definition: trace_replay.h:48
pthread_cond_t cond_sub
Definition: trace_replay.h:120
realtime_log_type
Definition: trace_replay.h:158
double total_bw
Definition: trace_replay.h:207
int working_set_size
Definition: trace_replay.h:94
double lat_min
Definition: trace_replay.h:204
Definition: trace_replay.h:160
double avg_bw
Definition: trace_replay.h:165
int trace_reset_count
Definition: trace_replay.h:227
unsigned long long cur_wbytes
Definition: trace_replay.h:59
unsigned long long __u64
Definition: trace_replay.h:260
#define MAX_THREADS
Definition: trace_replay.h:34
unsigned long long total_rbytes
Definition: trace_replay.h:55
double time
Definition: trace_replay.h:162
long long offset
Definition: trace_replay.h:145
Definition: trace_replay.h:80
long long wanted_io_count
Definition: trace_replay.h:92
unsigned int time_diff_cnt
Definition: trace_replay.h:65
long long start_page
Definition: trace_replay.h:110
double total_avg_req_size
Definition: trace_replay.h:214
struct trace_io_req * trace_buf
Definition: trace_replay.h:84
double total_size
Definition: trace_replay.h:178
int queue_depth
Definition: trace_replay.h:124
int io_size
Definition: trace_replay.h:96
int synthetic
Definition: trace_replay.h:91
int nr_trace
Definition: trace_replay.c:57
int touched_working_set_size
Definition: trace_replay.h:196
double time_diff
Definition: trace_replay.h:64
double lat_max
Definition: trace_replay.h:205
char __s8
Definition: trace_replay.h:246
int issynthetic
Definition: trace_replay.h:222
int buf_cur
Definition: trace_replay.h:132
double cur_bw
Definition: trace_replay.h:166
#define MAX_QDEPTH
Definition: trace_replay.h:33
double latency_max
Definition: trace_replay.h:51
int nr_thread
Definition: trace_replay.h:187
int done
Definition: trace_replay.h:138
int flags
Definition: trace_replay.h:76
int io_size
Definition: trace_replay.h:197
int synth_read
Definition: trace_replay.h:100
double avg_lat_var
Definition: trace_replay.h:203
double read_ratio
Definition: trace_replay.h:213
int queue_count
Definition: trace_replay.h:125
unsigned char __u8
Definition: trace_replay.h:255
unsigned int __u32
Definition: trace_replay.h:257
int trace_io_cnt
Definition: trace_replay.h:85
size_t bytes
Definition: trace_replay.h:146
int fd
Definition: trace_replay.h:90
double arrival_time
Definition: trace_replay.h:72
Definition: trace_replay.h:176
pthread_spinlock_t trace_lock
Definition: trace_replay.h:81
int blkno
Definition: trace_replay.h:74
double start_partition
Definition: trace_replay.h:177
int synth_rand
Definition: trace_replay.h:99
unsigned long long cur_bytes
Definition: trace_replay.h:57
pthread_spinlock_t stat_lock
Definition: trace_replay.h:47
unsigned int latency_count
Definition: trace_replay.h:52
#define STR_SIZE
Definition: trace_replay.h:35
unsigned short __u16
Definition: trace_replay.h:256
int active_count
Definition: trace_replay.h:126
double lat
Definition: trace_replay.h:167
struct trace_info_t traces[MAX_THREADS]
Definition: trace_replay.c:50
int utilization
Definition: trace_replay.h:195
io_context_t io_ctx
Definition: trace_replay.h:121
long mtype
Definition: trace_replay.h:172
long long __s64
Definition: trace_replay.h:252
short __s16
Definition: trace_replay.h:248
void synthetic_mix(struct trace_info_t *trace)
Definition: trace_replay.c:1147
int fsync_period
Definition: trace_replay.h:128
Definition: trace_replay.h:158