Commit f9d0c3e
Venkatesh Prasad
PS-9647: MySQL Perf Improvements
https://perconadev.atlassian.net/browse/PS-9647
This patch introduces a new hybrid data structure for MVCC ReadView from Enhanced MySQL
Typically, online transactions are short rather than long, and transaction IDs
increase continuously. To leverage these characteristics, a hybrid data
structure is used: a static array for consecutive short transaction IDs and a
vector for long transactions. With a 2048-byte array, up to 16,384 consecutive
active transaction IDs can be stored, each bit representing a transaction ID.
The minimum short transaction ID is used to differentiate between short and long
transactions.
IDs smaller than this minimum go into the long transaction vector, while IDs
equal to or greater than it are placed in the short transaction array.
For an ID in changes_visible, if it is below the minimum short transaction ID, a
direct query is made to the vector, which is efficient due to the generally
small number of long transactions.
If the ID is equal to or above the minimum short transaction ID, a bitwise query
is performed, with a time complexity of O(1), compared to the previous O(log n)
complexity. This improvement enhances efficiency and reduces cache migration
between NUMA nodes, as O(1) queries typically complete within a single CPU time
slice.
- In the short_rw_trx_ids_bitmap structure, MAX_SHORT_ACTIVE_BYTES is set to
65536, theoretically accommodating up to 524,288 consecutive short transaction
IDs.
- If the limit is exceeded, the oldest short transaction IDs are converted into
long transactions and stored in long_rw_trx_ids.
- Global long and short transactions are distinguished by min_short_valid_id:
IDs smaller than this value are treated as global long transactions, while IDs
equal to or greater are considered global short transactions.
During the copying process from the global active transaction list, the
short_rw_trx_ids_bitmap structure, which uses only one bit per transaction ID,
allows for much higher copying efficiency compared to the native MySQL solution.
For example, with 1000 active transactions, the native MySQL version would
require copying at least 8000 bytes, whereas the optimized solution may only
need a few hundred bytes. This results in a significant improvement in copying
efficiency.1 parent b715136 commit f9d0c3e
File tree
5 files changed
+494
-58
lines changed- storage/innobase
- include
- read
- trx
5 files changed
+494
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
176 | | - | |
177 | | - | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
181 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
182 | 204 | | |
183 | | - | |
| 205 | + | |
184 | 206 | | |
185 | 207 | | |
186 | 208 | | |
| |||
235 | 257 | | |
236 | 258 | | |
237 | 259 | | |
238 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
239 | 272 | | |
240 | 273 | | |
241 | 274 | | |
| |||
264 | 297 | | |
265 | 298 | | |
266 | 299 | | |
267 | | - | |
268 | | - | |
269 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
270 | 303 | | |
271 | 304 | | |
272 | 305 | | |
273 | 306 | | |
274 | 307 | | |
275 | 308 | | |
276 | 309 | | |
277 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
278 | 313 | | |
279 | 314 | | |
280 | 315 | | |
| |||
307 | 342 | | |
308 | 343 | | |
309 | 344 | | |
| 345 | + | |
310 | 346 | | |
311 | 347 | | |
312 | 348 | | |
| |||
322 | 358 | | |
323 | 359 | | |
324 | 360 | | |
325 | | - | |
| 361 | + | |
326 | 362 | | |
327 | 363 | | |
328 | 364 | | |
| |||
337 | 373 | | |
338 | 374 | | |
339 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
340 | 380 | | |
341 | 381 | | |
342 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
557 | 561 | | |
558 | 562 | | |
559 | 563 | | |
| |||
0 commit comments