[MDEV-11390] AliSQL: [perf] Issue#12 OPTIMIZE INNODB READ VIEW CREATION Created: 2016-11-29  Updated: 2019-02-05  Resolved: 2019-02-05

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Lixun Peng
Resolution: Won't Do Votes: 0
Labels: None

Epic Link: AliSQL patches

 Description   

read_view_open_now() and read_cursor_view_create_for_mysql() do a scan
of the list of all open transactions (trx_sys->trx_list) with the
kernel_mutex locked. On high-concurrency workloads (i.e. sysbench
read-only with number of threads >= 512) the cost of this scan is
huge.
 
The patch is ported from Percona Server, and contains 2 optimizations
to reduce the cost during read view creating.
 
1. Pre-allocate a read view structure for every transaction
 
No need to allocate a read view struct for each read_view_open_now()
call in a transaction, which is too expensive, allocate once and reused
it aterwards when need.
 
2. Maintain a trx_id array. While creating a read view, simply copy
the array without traversing the transaction rw_list.
 
Introduces a concept of "trx descriptors" which is a global
ordered array containing IDs of transactions in either TRX_ACTIVE or
TRX_PREPARED state. It allows to replace the trx_list scan in
read_view_open_now() and read_cursor_view_create_for_mysql() with a
binary search on the descriptors array and two memcpy()s.
The initial size of the descriptors array is 1000 slots (i.e. 8000
bytes). It is resized whenever we need more descriptors.
 
Since there is no transaction serialization numbers (i.e. trx->no) in the
descriptors array, this check was replaced by keeping a separate,
trx->no ordered list (trx_sys->trx_serial_list). Getting the current
minimum for the current read view is then simply a matter of getting
trx->no of the first element from trx_serial_list.

https://github.com/alibaba/AliSQL/commit/cb4273343da551de37cf9c46a257340fbc9a5127



 Comments   
Comment by Marko Mäkelä [ 2017-11-17 ]

This looks similar to what was done in MySQL 5.7. Maybe the patch was originally contributed to Oracle, and they decided to implement this differently?

Can you please confirm this? If this is the case, we would already have the equivalent change in MariaDB 10.2.2.

Comment by Sergey Vojtovich [ 2018-01-25 ]

With all recent ReadView changes introduced in 10.3, I believe MariaDB has a lot more advanced code. This patch is not applicable to MariaDB anymore.

Comment by Sergey Vojtovich [ 2019-02-05 ]

Closing per discussion with Lixun. MariaDB solution in 10.3 seems to be sufficient.

Generated at Thu Feb 08 07:49:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.