github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/testdata/compaction_setup_inputs_multilevel_write_amp (about) 1 # Init a multi-level compaction, because multi level write amp is lower 2 setup-inputs a a 3 L1 4 a.SET.1-b.SET.2 size=1 5 L2 6 a.SET.3-c.SET.4 size=1 7 L3 8 c.SET.3-d.SET.2 size=1 9 ---- 10 L1 11 000001:[a#1,1-b#2,1] 12 L2 13 000002:[a#3,1-c#4,1] 14 L3 15 000003:[c#3,1-d#2,1] 16 init-multi-level(1,2,3) 17 Original WriteAmp 2.00; ML WriteAmp 1.50 18 Original OverlappingRatio 1.00; ML OverlappingRatio 0.50 19 20 # Verify that the input level size should not affect the decision to conduct a multi 21 # level compaction. 22 setup-inputs a a 23 L1 24 a.SET.1-b.SET.2 size=10 25 L2 26 a.SET.3-c.SET.4 size=1 27 L3 28 c.SET.3-d.SET.2 size=1 29 ---- 30 L1 31 000001:[a#1,1-b#2,1] 32 L2 33 000002:[a#3,1-c#4,1] 34 L3 35 000003:[c#3,1-d#2,1] 36 init-multi-level(1,2,3) 37 Original WriteAmp 1.10; ML WriteAmp 1.09 38 Original OverlappingRatio 0.10; ML OverlappingRatio 0.09 39 40 # Don't init a multi-level compaction because write amp from multi level compaction is larger 41 setup-inputs a a 42 L1 43 a.SET.1-b.SET.2 size=1 44 L2 45 a.SET.3-c.SET.4 size=1 46 L3 47 c.SET.3-d.SET.2 size=3 48 ---- 49 L1 50 000001:[a#1,1-b#2,1] 51 L2 52 000002:[a#3,1-c#4,1] 53 54 # Init a multi-level compaction, but note that the second files in L2 and L3 do not get 55 # chosen, as they don't overlap with the original compaction. 56 setup-inputs a a 57 L1 58 a.SET.1-b.SET.2 size=6 59 L2 60 a.SET.3-c.SET.4 size=5 61 e.SET.1-h.SET.4 size=4 62 L3 63 c.SET.3-d.SET.2 size=6 64 e.SET.2-h.SET.4 size=4 65 ---- 66 L1 67 000001:[a#1,1-b#2,1] 68 L2 69 000002:[a#3,1-c#4,1] 70 L3 71 000004:[c#3,1-d#2,1] 72 init-multi-level(1,2,3) 73 Original WriteAmp 1.83; ML WriteAmp 1.55 74 Original OverlappingRatio 0.83; ML OverlappingRatio 0.55 75 76 # Init a multi-level compaction without an overlapping file in the lowest level. 77 setup-inputs a a 78 L1 79 a.SET.1-b.SET.2 size=6 80 L2 max-size=5 81 a.SET.3-c.SET.4 size=5 82 L3 83 e.SET.3-f.SET.2 size=100 84 ---- 85 L1 86 000001:[a#1,1-b#2,1] 87 L2 88 000002:[a#3,1-c#4,1] 89 init-multi-level(1,2,3) 90 Original WriteAmp 1.83; ML WriteAmp 1.00 91 Original OverlappingRatio 0.83; ML OverlappingRatio 0.00 92 93 # Init a multi-level compaction with no file in the lowest level. 94 setup-inputs a a 95 L1 96 a.SET.1-b.SET.2 size=6 97 L2 98 a.SET.3-c.SET.4 size=5 99 ---- 100 L1 101 000001:[a#1,1-b#2,1] 102 L2 103 000002:[a#3,1-c#4,1] 104 init-multi-level(1,2,3) 105 Original WriteAmp 1.83; ML WriteAmp 1.00 106 Original OverlappingRatio 0.83; ML OverlappingRatio 0.00 107 108 109 # Don't init a multi-level compaction, as the single level compaction results in a move ( 110 # write amp is 1) while the multi level compaction results in a Write Amp greater than 1 111 setup-inputs a a 112 L1 113 a.SET.1-b.SET.2 size=6 114 L2 115 e.SET.3-f.SET.2 size=100 116 L3 117 a.SET.3-c.SET.4 size=5 118 ---- 119 L1 120 000001:[a#1,1-b#2,1] 121 122 # Init a multi-level compaction, without an overlapping file in the (tie goes to the ML compaction!) 123 # intermediate and output levels 124 setup-inputs a a 125 L1 126 a.SET.1-b.SET.2 size=6 127 L2 128 e.SET.3-f.SET.2 size=1 129 L3 130 e.SET.4-f.SET.5 size=5 131 ---- 132 L1 133 000001:[a#1,1-b#2,1] 134 init-multi-level(1,2,3) 135 Original WriteAmp 1.00; ML WriteAmp 1.00 136 Original OverlappingRatio 0.00; ML OverlappingRatio 0.00 137 138 139 # Init a multi-level compaction which expands the intermediate level with a file that only 140 # overlaps with the lowest level. (I.e. it gets included during second setupInputs call) 141 setup-inputs a a 142 L1 143 a.SET.1-b.SET.2 size=3 144 L2 145 a.SET.2-b.SET.3 size=5 146 c.SET.2-d.SET.3 size=3 147 L3 148 a.SET.3-c.SET.4 size=3 149 ---- 150 L1 151 000001:[a#1,1-b#2,1] 152 L2 153 000002:[a#2,1-b#3,1] 154 000003:[c#2,1-d#3,1] 155 L3 156 000004:[a#3,1-c#4,1] 157 init-multi-level(1,2,3) 158 Original WriteAmp 2.67; ML WriteAmp 1.27 159 Original OverlappingRatio 1.67; ML OverlappingRatio 0.27 160 161 # Init a multi-level compaction which DOES NOT expand the input level with a file that 162 # only overlaps with the lowest level, even if it doesn't expand the output level keyspan. 163 # TODO(msbutler): include this file in the compaction 164 setup-inputs a a 165 L1 166 a.SET.1-b.SET.2 size=1 167 c.SET.2-d.SET.3 size=10 168 L2 169 a.SET.2-b.SET.3 size=1 170 L3 171 a.SET.3-c.SET.4 size=1 172 ---- 173 L1 174 000001:[a#1,1-b#2,1] 175 L2 176 000003:[a#2,1-b#3,1] 177 L3 178 000004:[a#3,1-c#4,1] 179 init-multi-level(1,2,3) 180 Original WriteAmp 2.00; ML WriteAmp 1.50 181 Original OverlappingRatio 1.00; ML OverlappingRatio 0.50 182 183 # Verify an expansion of the output level in the initial setupInputs will init a multi-level 184 # compaction. i.e. without the initial expansion, the multil level compaction would not have 185 # occurred. 186 setup-inputs a a 187 L1 188 a.SET.5-b.SET.6 size=1 189 L2 190 a.SET.3-c.SET.4 size=1 191 c.SET.3-d.SET.2 size=1 192 L3 193 c.SET.4-d.SET.4 size=3 194 ---- 195 L1 196 000001:[a#5,1-b#6,1] 197 L2 198 000002:[a#3,1-c#4,1] 199 000003:[c#3,1-d#2,1] 200 L3 201 000004:[c#4,1-d#4,1] 202 init-multi-level(1,2,3) 203 Original WriteAmp 3.00; ML WriteAmp 2.00 204 Original OverlappingRatio 2.00; ML OverlappingRatio 1.00 205 206 setup-inputs a a 207 L1 208 a.SET.5-b.SET.6 size=1 209 L2 210 a.SET.3-c.SET.4 size=1 211 L3 212 c.SET.4-d.SET.4 size=3 213 ---- 214 L1 215 000001:[a#5,1-b#6,1] 216 L2 217 000002:[a#3,1-c#4,1] 218 219 220 # Verify the second setupInputs call does not add an intermediate file if doing so would expand the 221 # output level (i.e. the pc.grow logic). 222 setup-inputs a a 223 L1 224 a.SET.1-b.SET.2 size=1 225 L2 226 a.SET.2-b.SET.3 size=1 227 d.SET.2-f.SET.2 size=1 228 L3 229 b.SET.1-d.SET.1 size=1 230 e.SET.4-f.SET.5 size=1 231 ---- 232 L1 233 000001:[a#1,1-b#2,1] 234 L2 235 000002:[a#2,1-b#3,1] 236 L3 237 000004:[b#1,1-d#1,1] 238 init-multi-level(1,2,3) 239 Original WriteAmp 2.00; ML WriteAmp 1.50 240 Original OverlappingRatio 1.00; ML OverlappingRatio 0.50 241 242 # Verify the max number of input levels equals 2. 243 setup-inputs a a 244 L1 245 a.SET.1-b.SET.2 size=6 246 L2 247 a.SET.3-c.SET.4 size=5 248 L3 249 c.SET.3-d.SET.2 size=2 250 L4 251 c.SET.4-d.SET.3 size=1 252 ---- 253 L1 254 000001:[a#1,1-b#2,1] 255 L2 256 000002:[a#3,1-c#4,1] 257 L3 258 000003:[c#3,1-d#2,1] 259 init-multi-level(1,2,3) 260 Original WriteAmp 1.83; ML WriteAmp 1.18 261 Original OverlappingRatio 0.83; ML OverlappingRatio 0.18 262 263 # Don't init multi-level compaction if the max size limit exceeded by initial setupInputs. 264 setup-inputs avail-bytes=10 a a 265 L1 266 a.SET.1-b.SET.2 size=6 267 L2 268 a.SET.5-b.SET.6 size=5 269 L3 270 a.SET.3-d.SET.4 size=3 271 ---- 272 L1 273 000001:[a#1,1-b#2,1] 274 L2 275 000002:[a#5,1-b#6,1] 276 277 # During second setupInputs call, allow output level expansion even if max size 278 # limit is exceeded, but not conduct intermediate level expansion. 279 # 280 # TODO(msbutler): If second setup inputs exceeds maxSize limits, should the first compaction get 281 # returned? 282 setup-inputs avail-bytes=20 a a 283 L1 284 a.SET.1-b.SET.2 size=4 285 L2 286 a.SET.5-b.SET.6 size=5 287 c.SET.4-e.SET.3 size=8 288 L3 289 a.SET.3-d.SET.4 size=2 290 d.SET.2-e.SET.2 size=2 291 ---- 292 L1 293 000001:[a#1,1-b#2,1] 294 L2 295 000002:[a#5,1-b#6,1] 296 L3 297 000004:[a#3,1-d#4,1] 298 000005:[d#2,1-e#2,1] 299 init-multi-level(1,2,3) 300 Original WriteAmp 2.25; ML WriteAmp 1.44 301 Original OverlappingRatio 1.25; ML OverlappingRatio 0.44 302 303 # Don't init a multi-level compaction if the start level is L5. 304 setup-inputs a a 305 L5 306 a.SET.1-b.SET.2 size=6 307 L6 308 a.SET.3-c.SET.4 size=5 309 ---- 310 L5 311 000001:[a#1,1-b#2,1] 312 L6 313 000002:[a#3,1-c#4,1] 314 315 # Don't init a multi-level compaction if the start level is L0. 316 setup-inputs a a 317 L0 318 a.SET.1-b.SET.2 size=6 319 L1 320 a.SET.3-c.SET.4 size=5 321 ---- 322 L0 323 000001:[a#1,1-b#2,1] 324 L1 325 000002:[a#3,1-c#4,1] 326 327 # Verify a multi level compaction will not init on a compacting file. 328 setup-inputs a a 329 L1 330 a.SET.1-b.SET.2 size=1 331 L2 332 a.SET.3-c.SET.4 size=1 333 L3 334 c.SET.3-d.SET.2 size=1 compacting 335 ---- 336 L1 337 000001:[a#1,1-b#2,1] 338 L2 339 000002:[a#3,1-c#4,1]