[MDEV-28525] Some conditions around btr_latch_mode could be eliminated Created: 2022-05-10  Updated: 2022-06-06  Resolved: 2022-06-06

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.6.9, 10.7.5, 10.8.4, 10.9.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: performance


 Description   

The types btr_latch_mode and mtr_memo_type_t are partly derived from rw_lock_type_t. Despite that, some code for converting between them is using conditions instead of bitwise arithmetics.

If we align btr_latch_mode better with mtr_memo_type_t, some conversions by bitwise arithmetics will become possible. For example, the arithmetic expression

	const rw_lock_type_t mode = rw_lock_type_t(
		latch_mode & (RW_X_LATCH | RW_S_LATCH));

would replace conditional code like the following:

	mode = latch_mode == BTR_MODIFY_LEAF ? RW_X_LATCH : RW_S_LATCH;


Generated at Thu Feb 08 10:01:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.