Bug #101658 Rollback segment can be initialized parallel
Submitted: 18 Nov 2020 7:02 Modified: 2 Jun 2021 13:41
Reporter: Zheng Lai (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:5.7, 8.0 OS:Any
Assigned to: Rahul Agarkar CPU Architecture:Any
Tags: Contribution

[18 Nov 2020 7:02] Zheng Lai
Description:
In server startup procedure, InnoDB need to initialize the rollback segments to collect information of transactions which need to rollback. there're 128 rollback segments and they're initialized serially. The initialization of rollback segments will take 1-2 seconds sometime.

How to repeat:
Add some instrument code to print out the execution time of function trx_sys_init_at_db_start.

Suggested fix:
The initialization can be optimized to make it parallel.
[18 Nov 2020 7:07] Zheng Lai
patch for initialization rollback segments parallel

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: rseg_init_speedup.patch (application/octet-stream, text), 20.53 KiB.

[18 Nov 2020 7:08] Zheng Lai
I've uploaded a patch for this, it can be apply to 8.0.22, please evaluate it, thanks.
[18 Nov 2020 13:44] MySQL Verification Team
Hi Mr. Lai,

Thank you very much for your performance enhancement report.

However, thank you even more for your sizeable patch that is a great starting point for initialising rollback segments in parallel. This would make an observable performance improvement in many cases.

Verified as reported.
[27 May 2021 6:00] Rahul Agarkar
Thanks Zheng Lai for the contribution. However, to avoid introducing a new variable to control the parallelisation, the contribution has been modified a little to calculate the number of threads based on the number of cores available. Also, the number of threads initializing the rollback segments has been capped to 4.
[2 Jun 2021 13:41] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 8.0.26 release, and here's the proposed changelog entry from the documentation team:

Rollback segments are now initialized in parallel during startup.
Previously, rollback segments were initialized serially.
[3 Jun 2021 12:58] MySQL Verification Team
Thank you, Daniel .....
[8 Sep 2021 11:22] Daniel Price
Posted by developer:
 
The 8.0.26 changelog entry was revised as follows: 

Rollback segments are now initialized in parallel during startup.
Previously, rollback segments were initialized serially. 

Thanks to Zheng Lai and the Tencent Cloud-Native Database team for
submitting the contribution this bug fix is based on.