-
Notifications
You must be signed in to change notification settings - Fork 465
/
compaction_setup_inputs_multilevel_write_amp
339 lines (318 loc) · 7.03 KB
/
compaction_setup_inputs_multilevel_write_amp
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# Init a multi-level compaction, because multi level write amp is lower
setup-inputs a a
L1
a.SET.1-b.SET.2 size=1
L2
a.SET.3-c.SET.4 size=1
L3
c.SET.3-d.SET.2 size=1
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
L3
000003:[c#3,1-d#2,1]
init-multi-level(1,2,3)
Original WriteAmp 2.00; ML WriteAmp 1.50
Original OverlappingRatio 1.00; ML OverlappingRatio 0.50
# Verify that the input level size should not affect the decision to conduct a multi
# level compaction.
setup-inputs a a
L1
a.SET.1-b.SET.2 size=10
L2
a.SET.3-c.SET.4 size=1
L3
c.SET.3-d.SET.2 size=1
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
L3
000003:[c#3,1-d#2,1]
init-multi-level(1,2,3)
Original WriteAmp 1.10; ML WriteAmp 1.09
Original OverlappingRatio 0.10; ML OverlappingRatio 0.09
# Don't init a multi-level compaction because write amp from multi level compaction is larger
setup-inputs a a
L1
a.SET.1-b.SET.2 size=1
L2
a.SET.3-c.SET.4 size=1
L3
c.SET.3-d.SET.2 size=3
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
# Init a multi-level compaction, but note that the second files in L2 and L3 do not get
# chosen, as they don't overlap with the original compaction.
setup-inputs a a
L1
a.SET.1-b.SET.2 size=6
L2
a.SET.3-c.SET.4 size=5
e.SET.1-h.SET.4 size=4
L3
c.SET.3-d.SET.2 size=6
e.SET.2-h.SET.4 size=4
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
L3
000004:[c#3,1-d#2,1]
init-multi-level(1,2,3)
Original WriteAmp 1.83; ML WriteAmp 1.55
Original OverlappingRatio 0.83; ML OverlappingRatio 0.55
# Init a multi-level compaction without an overlapping file in the lowest level.
setup-inputs a a
L1
a.SET.1-b.SET.2 size=6
L2 max-size=5
a.SET.3-c.SET.4 size=5
L3
e.SET.3-f.SET.2 size=100
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
init-multi-level(1,2,3)
Original WriteAmp 1.83; ML WriteAmp 1.00
Original OverlappingRatio 0.83; ML OverlappingRatio 0.00
# Init a multi-level compaction with no file in the lowest level.
setup-inputs a a
L1
a.SET.1-b.SET.2 size=6
L2
a.SET.3-c.SET.4 size=5
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
init-multi-level(1,2,3)
Original WriteAmp 1.83; ML WriteAmp 1.00
Original OverlappingRatio 0.83; ML OverlappingRatio 0.00
# Don't init a multi-level compaction, as the single level compaction results in a move (
# write amp is 1) while the multi level compaction results in a Write Amp greater than 1
setup-inputs a a
L1
a.SET.1-b.SET.2 size=6
L2
e.SET.3-f.SET.2 size=100
L3
a.SET.3-c.SET.4 size=5
----
L1
000001:[a#1,1-b#2,1]
# Init a multi-level compaction, without an overlapping file in the (tie goes to the ML compaction!)
# intermediate and output levels
setup-inputs a a
L1
a.SET.1-b.SET.2 size=6
L2
e.SET.3-f.SET.2 size=1
L3
e.SET.4-f.SET.5 size=5
----
L1
000001:[a#1,1-b#2,1]
init-multi-level(1,2,3)
Original WriteAmp 1.00; ML WriteAmp 1.00
Original OverlappingRatio 0.00; ML OverlappingRatio 0.00
# Init a multi-level compaction which expands the intermediate level with a file that only
# overlaps with the lowest level. (I.e. it gets included during second setupInputs call)
setup-inputs a a
L1
a.SET.1-b.SET.2 size=3
L2
a.SET.2-b.SET.3 size=5
c.SET.2-d.SET.3 size=3
L3
a.SET.3-c.SET.4 size=3
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#2,1-b#3,1]
000003:[c#2,1-d#3,1]
L3
000004:[a#3,1-c#4,1]
init-multi-level(1,2,3)
Original WriteAmp 2.67; ML WriteAmp 1.27
Original OverlappingRatio 1.67; ML OverlappingRatio 0.27
# Init a multi-level compaction which DOES NOT expand the input level with a file that
# only overlaps with the lowest level, even if it doesn't expand the output level keyspan.
# TODO(msbutler): include this file in the compaction
setup-inputs a a
L1
a.SET.1-b.SET.2 size=1
c.SET.2-d.SET.3 size=10
L2
a.SET.2-b.SET.3 size=1
L3
a.SET.3-c.SET.4 size=1
----
L1
000001:[a#1,1-b#2,1]
L2
000003:[a#2,1-b#3,1]
L3
000004:[a#3,1-c#4,1]
init-multi-level(1,2,3)
Original WriteAmp 2.00; ML WriteAmp 1.50
Original OverlappingRatio 1.00; ML OverlappingRatio 0.50
# Verify an expansion of the output level in the initial setupInputs will init a multi-level
# compaction. i.e. without the initial expansion, the multil level compaction would not have
# occurred.
setup-inputs a a
L1
a.SET.5-b.SET.6 size=1
L2
a.SET.3-c.SET.4 size=1
c.SET.3-d.SET.2 size=1
L3
c.SET.4-d.SET.4 size=3
----
L1
000001:[a#5,1-b#6,1]
L2
000002:[a#3,1-c#4,1]
000003:[c#3,1-d#2,1]
L3
000004:[c#4,1-d#4,1]
init-multi-level(1,2,3)
Original WriteAmp 3.00; ML WriteAmp 2.00
Original OverlappingRatio 2.00; ML OverlappingRatio 1.00
setup-inputs a a
L1
a.SET.5-b.SET.6 size=1
L2
a.SET.3-c.SET.4 size=1
L3
c.SET.4-d.SET.4 size=3
----
L1
000001:[a#5,1-b#6,1]
L2
000002:[a#3,1-c#4,1]
# Verify the second setupInputs call does not add an intermediate file if doing so would expand the
# output level (i.e. the pc.grow logic).
setup-inputs a a
L1
a.SET.1-b.SET.2 size=1
L2
a.SET.2-b.SET.3 size=1
d.SET.2-f.SET.2 size=1
L3
b.SET.1-d.SET.1 size=1
e.SET.4-f.SET.5 size=1
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#2,1-b#3,1]
L3
000004:[b#1,1-d#1,1]
init-multi-level(1,2,3)
Original WriteAmp 2.00; ML WriteAmp 1.50
Original OverlappingRatio 1.00; ML OverlappingRatio 0.50
# Verify the max number of input levels equals 2.
setup-inputs a a
L1
a.SET.1-b.SET.2 size=6
L2
a.SET.3-c.SET.4 size=5
L3
c.SET.3-d.SET.2 size=2
L4
c.SET.4-d.SET.3 size=1
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]
L3
000003:[c#3,1-d#2,1]
init-multi-level(1,2,3)
Original WriteAmp 1.83; ML WriteAmp 1.18
Original OverlappingRatio 0.83; ML OverlappingRatio 0.18
# Don't init multi-level compaction if the max size limit exceeded by initial setupInputs.
setup-inputs avail-bytes=10 a a
L1
a.SET.1-b.SET.2 size=6
L2
a.SET.5-b.SET.6 size=5
L3
a.SET.3-d.SET.4 size=3
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#5,1-b#6,1]
# During second setupInputs call, allow output level expansion even if max size
# limit is exceeded, but not conduct intermediate level expansion.
#
# TODO(msbutler): If second setup inputs exceeds maxSize limits, should the first compaction get
# returned?
setup-inputs avail-bytes=20 a a
L1
a.SET.1-b.SET.2 size=4
L2
a.SET.5-b.SET.6 size=5
c.SET.4-e.SET.3 size=8
L3
a.SET.3-d.SET.4 size=2
d.SET.2-e.SET.2 size=2
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#5,1-b#6,1]
L3
000004:[a#3,1-d#4,1]
000005:[d#2,1-e#2,1]
init-multi-level(1,2,3)
Original WriteAmp 2.25; ML WriteAmp 1.44
Original OverlappingRatio 1.25; ML OverlappingRatio 0.44
# Don't init a multi-level compaction if the start level is L5.
setup-inputs a a
L5
a.SET.1-b.SET.2 size=6
L6
a.SET.3-c.SET.4 size=5
----
L5
000001:[a#1,1-b#2,1]
L6
000002:[a#3,1-c#4,1]
# Don't init a multi-level compaction if the start level is L0.
setup-inputs a a
L0
a.SET.1-b.SET.2 size=6
L1
a.SET.3-c.SET.4 size=5
----
L0
000001:[a#1,1-b#2,1]
L1
000002:[a#3,1-c#4,1]
# Verify a multi level compaction will not init on a compacting file.
setup-inputs a a
L1
a.SET.1-b.SET.2 size=1
L2
a.SET.3-c.SET.4 size=1
L3
c.SET.3-d.SET.2 size=1 compacting
----
L1
000001:[a#1,1-b#2,1]
L2
000002:[a#3,1-c#4,1]