Skip to content

Commit 1f682bc

Browse files
committedDec 2, 2024
Improvement documentation
1 parent ad603bd commit 1f682bc

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
 

‎Chapter8.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,11 @@ It's worth noting that the specifics of how transaction throttling is implemente
669669

670670
Users tend to notice a decline in low-concurrency performance more easily, while improvements in high-concurrency performance are often harder to perceive. Therefore, maintaining low-concurrency performance is crucial, as it directly affects user experience and the willingness to upgrade.
671671

672-
According to extensive user feedback, after upgrading to MySQL 8.0, users have generally perceived a decline in performance, particularly in batch insert and join operations. This downward trend has become more evident with each version update. Additionally, some MySQL enthusiasts and testers have reported performance degradation in multiple sysbench tests after upgrading.
672+
According to extensive user feedback, after upgrading to MySQL 8.0, users have generally perceived a decline in performance, particularly in batch insert and join operations. This downward trend has become more evident in higher versions of MySQL. Additionally, some MySQL enthusiasts and testers have reported performance degradation in multiple sysbench tests after upgrading.
673673

674674
Can these performance issues be avoided? Or, more specifically, how should we scientifically assess the ongoing trend of performance decline? These are important questions to consider.
675675

676-
Although the official team continues to optimize, the gradual deterioration of performance cannot be overlooked. In certain scenarios, there may appear to be improvements, but this does not mean that performance in all scenarios is equally optimized. Performance optimization is a very complex task that can easily lead to
677-
generalizations. Moreover, it's also easy to optimize performance for specific scenarios at the cost of degrading performance in other areas.
676+
Although the official team continues to optimize, the gradual deterioration of performance cannot be overlooked. In certain scenarios, there may appear to be improvements, but this does not mean that performance in all scenarios is equally optimized. Moreover, it's also easy to optimize performance for specific scenarios at the cost of degrading performance in other areas.
678677

679678
### 8.4.1 The Root Causes of MySQL Performance Decline
680679

@@ -743,25 +742,19 @@ Unfortunately, many times it is precisely the motivations behind these code impr
743742
documentation:
744743

745744
```
746-
std::deque (double-ended queue) is an indexed sequence container that
747-
allows fast insertion and deletion at both its beginning and its end.
748-
In addition, insertion and deletion at either end of a deque never
749-
invalidates pointers or references to the rest of the elements.
750-
751-
As opposed to std::vector, the elements of a deque are not stored
752-
contiguously: typical implementations use a sequence of individually
753-
allocated fixed-size arrays, with additional bookkeeping, which means
754-
indexed access to deque must perform two pointer dereferences,
755-
compared to vector's indexed access which performs only one.
756-
757-
The storage of a deque is automatically expanded and contracted as
758-
needed. Expansion of a deque is cheaper than the expansion of a
759-
std::vector because it does not involve copying of the existing
760-
elements to a new memory location. On the other hand, deques typically
761-
have large minimal memory cost; a deque holding just one element has
762-
to allocate its full internal array (e.g. 8 times the object size on
763-
64-bit libstdc++; 16 times the object size or 4096 bytes, whichever is
764-
larger, on 64-bit libc++).
745+
std::deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion at both its
746+
beginning and its end. In addition, insertion and deletion at either end of a deque never invalidates pointers or
747+
references to the rest of the elements.
748+
749+
As opposed to std::vector, the elements of a deque are not stored contiguously: typical implementations use a sequence
750+
of individually allocated fixed-size arrays, with additional bookkeeping, which means indexed access to deque must
751+
perform two pointer dereferences, compared to vector's indexed access which performs only one.
752+
753+
The storage of a deque is automatically expanded and contracted as needed. Expansion of a deque is cheaper than the
754+
expansion of a std::vector because it does not involve copying of the existing elements to a new memory location. On
755+
the other hand, deques typically have large minimal memory cost; a deque holding just one element has to allocate its
756+
full internal array (e.g. 8 times the object size on 64-bit libstdc++; 16 times the object size or 4096 bytes,
757+
whichever is larger, on 64-bit libc++).
765758
766759
The complexity (efficiency) of common operations on deques is as follows:
767760
Random access - constant O(1).
@@ -975,6 +968,7 @@ inline void rec_init_offsets_comp_ordinary(const rec_t *rec, bool temp,
975968
default:
976969
ut_ad(false);
977970
}
971+
...
978972
```
979973
980974
From the above code, it is clear that with the introduction of the instant add/drop column feature, the ***rec_init_offsets_comp_ordinary*** function has become noticeably more complex, introducing more function calls and adding a switch statement that severely impacts cache optimization. Since this function is called frequently, it directly impacts the performance of update index, batch inserts, and joins, resulting in a major performance hit.
@@ -1156,15 +1150,21 @@ The so-called 'premature optimization' is the root of all evil, and it does not
11561150

11571151
The main reasons for the decline in write performance are related to MTR commit issues, instant add/drop column, and several other factors. These are difficult to optimize in traditional ways. However, users can compensate for the performance drop through PGO optimization. With a proper strategy, the performance can generally be kept stable.
11581152

1159-
For batch insert performance degradation, our open-source version [64] replaces the official deque with an improved list implementation. This primarily addresses memory efficiency issues and can partially alleviate performance decline. By combining PGO optimization with our open-source version, batch insert performance can approach that of MySQL 5.7. Users can also leverage multiple threads for concurrent batch processing, fully utilizing the improved concurrency of the redo log, which can significantly boost batch insert performance.
1153+
For batch insert performance degradation, our open-source version [64] replaces the official deque with an improved list implementation. This primarily addresses memory efficiency issues and can partially alleviate performance decline. By combining PGO optimization with our open-source version, batch insert performance can approach that of MySQL 5.7.
1154+
1155+
<img src="media/image-bulk-insert-optimize.png" alt="image-bulk-insert-optimize.png" style="zoom:150%;" />
1156+
1157+
Figure 8-39. Optimized MySQL 8.0.40 with PGO performs roughly on par with version 5.7.
1158+
1159+
Users can also leverage multiple threads for concurrent batch processing, fully utilizing the improved concurrency of the redo log, which can significantly boost batch insert performance.
11601160

11611161
Regarding update index issues, due to the inevitable addition of new code, PGO optimization can help mitigate this problem. Our PGO version [64] can significantly alleviate this issue.
11621162

11631163
For read performance, particularly join performance, we have made substantial improvements, including fixing inline issues and making other optimizations. With the addition of PGO, join performance can be increased by over 30% compared to the official version.
11641164

11651165
<img src="media/image-join-improve.png" alt="image-join-improve.png" style="zoom:150%;" />
11661166

1167-
Figure 8-39. Join performance optimization with PGO leads to significant
1167+
Figure 8-40. Join performance optimization with PGO leads to significant
11681168
improvements.
11691169

11701170
We will continue to invest time in optimizing low-concurrency performance. This process is long but involves numerous areas that need improvement.

‎media/image-bulk-insert-optimize.png

15.1 KB
Loading

0 commit comments

Comments
 (0)