Bug #68069 | mtr_memo_release and dyn_array together are very inefficient | ||
---|---|---|---|
Submitted: | 10 Jan 2013 20:02 | Modified: | 12 Feb 2013 20:06 |
Reporter: | Domas Mituzas | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.1, maybe others | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[10 Jan 2013 20:02]
Domas Mituzas
[13 Jan 2013 15:13]
MySQL Verification Team
Thanks Domas!
[13 Jan 2013 19:38]
Marko Mäkelä
Domas, I noticed this O(n^2) in mtr_memo_release() some time ago when I analyzed the stack trace in Bug#67124 (an alleged performance regression in CREATE INDEX, which I was not able to verify). Unfortunately, this was not visible in my testing, and my patch did not make much difference. Thanks to your bug report, we can now develop a test case for this regression. As far as I can tell, the dyn_array and mtr_memo code has remained largely the same since MySQL 4.0, maybe even 3.23.
[12 Feb 2013 20:06]
John Russell
Added to changelog for 5.5.31, 5.6.11: Performance was improved for operations on tables with many rows that were deleted but not yet purged. The speedup applies mainly to workloads that perform bulk deletes, or updates to the primary key columns, and where the system is busy enough to experience purge lag.
[20 Apr 2013 13:38]
Laurynas Biveinis
5.5$ bzr log -r 4165 ------------------------------------------------------------ revno: 4165 committer: Marko Mäkelä <marko.makela@oracle.com> branch nick: mysql-5.5 timestamp: Thu 2013-01-17 17:30:13 +0200 message: Bug#16138582 MTR_MEMO_RELEASE AND DYN_ARRAY TOGETHER ARE VERY INEFFICIENT Get rid of O(n^2) scan in dyn array (mtr->memo) operations, accessing the dyn array blocks directly. dyn_array_get_last_block(), dyn_array_get_next_block(), dyn_array_get_prev_block(): Define as a constness-preserving macro. Add const qualifiers to many dyn_array functions. mtr_memo_slot_release_func(): Renamed from mtr_memo_slot_release(): Make mtr_t* a debug-only parameter. Assume that slot->object != NULL. mtr_memo_pop_all(): Access the dyn_array blocks directly, replacing O(n^2) operation with O(n). mtr_memo_release(): Access the dyn_array blocks directly, replacing O(n^2) operation with O(n). This caused the performance problem. rb#1540 approved by Jimmy Yang 5.6$ bzr log -r 4638 -n0 ------------------------------------------------------------ revno: 4638 [merge] committer: Marko Mäkelä <marko.makela@oracle.com> branch nick: mysql-5.6 timestamp: Thu 2013-01-17 17:45:20 +0200 message: Merge mysql-5.5 to mysql-5.6. ------------------------------------------------------------ revno: 2875.417.145 committer: Marko Mäkelä <marko.makela@oracle.com> branch nick: mysql-5.5 timestamp: Thu 2013-01-17 17:30:13 +0200 message: Bug#16138582 MTR_MEMO_RELEASE AND DYN_ARRAY TOGETHER ARE VERY INEFFICIENT