Bug #114361 | Unaligned Delegate's lock reduces performance | ||
---|---|---|---|
Submitted: | 15 Mar 2024 1:53 | Modified: | 18 Mar 2024 1:57 |
Reporter: | Xizhe Zhang (OCA) | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S5 (Performance) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | alignment, commit, lock |
[15 Mar 2024 1:53]
Xizhe Zhang
[15 Mar 2024 10:54]
MySQL Verification Team
Hi Mr. Zheng, Thank you for your bug report. We do not understand how adding a global static variable that is not used at all in the code can cause performance degradation. However, the rest of your analysis is impressive, including the profiling. Your remedy is simple and acceptable. This is now a verified performance improvement report, with the patch that is added. This is an improvement that is intended for 8.0 and higher versions. Thank you for your contribution.
[15 Mar 2024 10:56]
MySQL Verification Team
Upon some further analysis, it could be applied to other locking mechanisms in MySQL, but this will require further, internal, analysis.
[15 Mar 2024 13:07]
Xizhe Zhang
Sorry for not clarifying the relationship between "global static variable" and "transaction_delegate->lock". The uninitialized "global static variable" is located in the BSS (Better Save Space) section. During compilation, the memory address of the variable can be determined and stored in the symbol table of the binary file. The following is the initialization function of "transaction_delegate". Although the object is dynamically allocated, it uses the memory space of the static array "place_trans_mem". This array's memory is aligned according to 16B. When we define a "global static variable", its position in the BSS section is earlier than "place_trans_mem", increasing the address of "place_trans_mem". As a result, "transaction_delegate->lock" is not aligned according to 64B as described before. int delegates_init() { // align as 16B alignas(Trans_delegate) static char place_trans_mem[sizeof(Trans_delegate)]; ... transaction_delegate = new (place_trans_mem) Trans_delegate; }
[18 Mar 2024 2:55]
Xizhe Zhang
Hello, Verification Team, this is my patch.
Attachment: delegate_lock.gitlog (application/octet-stream, text), 1.68 KiB.
[19 Mar 2024 11:11]
MySQL Verification Team
Hi Mr. Zhang, Thank you for your patch. We shall immediately make your patch available to our Development team. Thanks again !!!!
[14 Aug 2024 8:23]
Libing Song
Hi MySQL Team, The bug is still there. It is a one line fix which should be easy to fix.
[14 Aug 2024 9:34]
MySQL Verification Team
Hi Mr. Zhang, We are in the midst of the vacation time and our Development is currently overloaded. Hence, we all need some patience ......