You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Chapter8.md
+24-24
Original file line number
Diff line number
Diff line change
@@ -669,12 +669,11 @@ It's worth noting that the specifics of how transaction throttling is implemente
669
669
670
670
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.
671
671
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.
673
673
674
674
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.
675
675
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.
678
677
679
678
### 8.4.1 The Root Causes of MySQL Performance Decline
680
679
@@ -743,25 +742,19 @@ Unfortunately, many times it is precisely the motivations behind these code impr
743
742
documentation:
744
743
745
744
```
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++).
765
758
766
759
The complexity (efficiency) of common operations on deques is as follows:
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
1156
1150
1157
1151
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.
1158
1152
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.
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.
1160
1160
1161
1161
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.
1162
1162
1163
1163
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.
0 commit comments