forked from ucare-uchicago/trace-edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace-editor.py
executable file
·125 lines (115 loc) · 6.08 KB
/
trace-editor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
#title :trace-editor.py
#description :process traces
#author :Vincentius Martin
#date :-
#version :0.1
#usage :see readme
#notes :
#python_version :2.7.5+
#==============================================================================
# import default
import sys
import argparse
from os import listdir
sys.path.insert(0, './scripts/')
import trace_modifier
import preprocess_trace
import traces_combiner
import busy_load
import filter_raid
import iopsimbalance
import toplargeio
import cuttrace
import characteristic
# end of import part
# define global variables
requestlist = []
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-file", help="trace file to process",type=str)
#parser.add_argument("-files", nargs='+', help="trace files to process",type=str)
parser.add_argument("-dir", help="directory file to process",type=str)
parser.add_argument("-produceTrace", help="produce preprocessed trace", action='store_true')
parser.add_argument("-preprocessMSTrace", help="preprocess the MS trace into disksim ascii format", action='store_true')
parser.add_argument("-preprocessBlkReplayTrace", help="preprocess the blkreplay trace into disksim ascii format", action='store_true')
parser.add_argument("-preprocessUnixBlkTrace", help="preprocess the blkreplay trace into disksim ascii format", action='store_true')
parser.add_argument("-breaktoraid", help="create a RAID-0 subtrace", action='store_true')
parser.add_argument("-ioimbalance", help="check RAID IO Imbalance", action='store_true')
parser.add_argument("-combine", help="combine preprocessed traces inside a directory", action='store_true')
parser.add_argument("-toplargeio", help="get n top large io", action='store_true')
parser.add_argument("-cuttrace", help="cut a trace", action='store_true')
parser.add_argument("-getLargestIO", help="get largest IO", action='store_true')
parser.add_argument("-offset", help="offset", choices=['0','32','64','128','256','512','1024'], default = '0')
parser.add_argument("-filter", help="filter specific type", choices=['all','write','read'], default='all')
parser.add_argument("-devno", help="disk/device number", type=int, default=0)
parser.add_argument("-duration", help="how many minutes", type=float, default=1.0)
parser.add_argument("-mostLoaded", help="most loaded", action='store_true')
parser.add_argument("-mostRandomWrite", help="most random write", action='store_true')
parser.add_argument("-busiest", help="busiest", action='store_true')
parser.add_argument("-largestAverage", help="largest average", action='store_true')
parser.add_argument("-characteristic", help="characteristic of a trace", action='store_true')
parser.add_argument("-top", help="top n", type=int, default=1)
parser.add_argument("-resize", help="resize a trace", type=float, default=1.0)
parser.add_argument("-rerate", help="rerate a trace", type=float, default=1.0)
parser.add_argument("-ndisk", help="n disk for RAID", type=int, default=2)
parser.add_argument("-stripe", help="RAID stripe unit size in byte", type=int, default=4096)
parser.add_argument("-granularity", help="granularity to check RAID IO imbalance in minutes", type=int, default=1)
parser.add_argument("-timerange", help="time range to cut the trace", type=float, nargs = 2)
args = parser.parse_args()
# parse to request list
if (args.preprocessMSTrace): #preprocess
if (not args.file and args.dir):
for ftrace in listdir("in/" + args.dir):
preprocess_trace.preprocessMSTrace(args.dir + "/" + ftrace, args.filter)
else:
preprocess_trace.preprocessMSTrace(args.file, args.filter)
elif (args.preprocessBlkReplayTrace): #preprocess
if (not args.file and args.dir):
for ftrace in listdir("in/" + args.dir):
preprocess_trace.preprocessBlkReplayTrace(args.dir + "/" + ftrace, args.filter)
else:
preprocess_trace.preprocessBlkReplayTrace(args.file, args.filter)
elif (args.preprocessUnixBlkTrace): #preprocess
if (not args.file and args.dir):
for ftrace in listdir("in/" + args.dir):
preprocess_trace.preprocessUnixBlkTrace(args.dir + "/" + ftrace, args.filter)
else:
preprocess_trace.preprocessUnixBlkTrace(args.file, args.filter)
elif (args.getLargestIO):
toplargeio.getLargestIO(args.file)
elif (args.breaktoraid):
filter_raid.createAllRaidFiles(args.file, args.ndisk, args.stripe)
elif (args.ioimbalance):
iopsimbalance.checkIOImbalance(filter_raid.createAllRaidList(args.file,args.ndisk,args.stripe), args.granularity)
elif (args.combine):
traces_combiner.combine(args.dir)
elif args.mostLoaded or args.busiest or args.largestAverage or args.mostRandomWrite: #need combine
if args.busiest:
busy_load.checkCongestedTime(args.file, "1", args.devno, args.duration, args.top)
elif args.mostLoaded:
busy_load.checkCongestedTime(args.file, "2", args.devno, args.duration, args.top)
elif args.largestAverage:
busy_load.checkCongestedTime(args.file, "3", args.devno, args.duration, args.top)
elif args.mostRandomWrite:
busy_load.checkCongestedTime(args.file, "4", args.devno, args.duration, args.top)
elif (args.characteristic):
if (not args.file and args.dir):
for ftrace in listdir("in/" + args.dir):
characteristic.getTraceInfo(args.dir + "/" + ftrace)
else:
characteristic.getTraceInfo(args.file)
elif (args.toplargeio):
toplargeio.getTopLargeIO(args.file, args.offset, args.devno, args.duration, args.top)
elif (args.cuttrace):
cuttrace.cut(args.file, args.timerange[0], args.timerange[1], args.devno)
elif (args.resize or args.rerate): #modify a trace
with open("in/" + args.file) as f:
for line in f:
requestlist.append(line.rstrip().split(" "))
if args.resize != 1.0 or args.rerate!= 1.0:
if (args.resize != 1.0):
requestlist = trace_modifier.resize(requestlist,args.resize)
if (args.rerate != 1.0):
requestlist = trace_modifier.modifyRate(requestlist,args.rerate)
trace_modifier.printRequestList(requestlist, args.file)