Bug #104639 Simplify the purge_sys->read_view creation to reduce mutex contention
Submitted: 17 Aug 2021 7:16 Modified: 18 Aug 2021 12:27
Reporter: Fangxin Flou (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[17 Aug 2021 7:16] Fangxin Flou
Description:
Currently the purge_sys->read_view is copied from oldest read view or create a new one by taking the trx_sys->mutex lock, so heavy work loading will block purge threads to reclaim the undo space.

How to repeat:
run benchmark, and check the purge progress.

Suggested fix:
We don't need to copy the whole read view or create a new one by copy the  trx_sys->rw_trx_ids array.

Actually we just need to get min(min_active_id - 1, oldest_view->low_limit_no) as the upper_limit_id/low_limit_no/low_limit_id of purge_sys->read_view, by maintain a atomic variables of the oldest read view's low_limit_no, we can skip acquiring of the trx_sys->mutex.

Which will make purge faster than before.
[18 Aug 2021 12:27] MySQL Verification Team
Hi Mr. Flou,

Thank you for your performance improvement request.

We consider that it has sufficient merit to be considered in more detail.

Verified as the performance improvement request.
[18 Aug 2021 12:30] MySQL Verification Team
Just setting the version correctly.