Skip to content

Commit 8321263

Browse files
committed
MDEV-27935: Enable performance_schema profiling for trx_rseg_t latch
- In 10.6, trx_rseg_t mutex was ported to use latch. As part of this porting profiling of the patch was removed. This patch reenables it given that the said latch continues to occupy the top-slots in the contention list.
1 parent 164a6aa commit 8321263

File tree

12 files changed

+27
-19
lines changed

12 files changed

+27
-19
lines changed

mysql-test/suite/perfschema/r/sxlock_func.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ wait/synch/rwlock/innodb/fil_space_latch
1212
wait/synch/rwlock/innodb/lock_latch
1313
wait/synch/rwlock/innodb/trx_i_s_cache_lock
1414
wait/synch/rwlock/innodb/trx_purge_latch
15+
wait/synch/rwlock/innodb/trx_rseg_latch
1516
TRUNCATE TABLE performance_schema.events_waits_history_long;
1617
TRUNCATE TABLE performance_schema.events_waits_history;
1718
TRUNCATE TABLE performance_schema.events_waits_current;
@@ -36,6 +37,7 @@ WHERE event_name LIKE 'wait/synch/rwlock/innodb/%'
3637
AND event_name NOT IN
3738
('wait/synch/rwlock/innodb/btr_search_latch',
3839
'wait/synch/rwlock/innodb/dict_operation_lock',
40+
'wait/synch/rwlock/innodb/trx_rseg_latch',
3941
'wait/synch/rwlock/innodb/trx_purge_latch')
4042
ORDER BY event_name;
4143
event_name

mysql-test/suite/perfschema/t/sxlock_func.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ WHERE event_name LIKE 'wait/synch/rwlock/innodb/%'
4949
AND event_name NOT IN
5050
('wait/synch/rwlock/innodb/btr_search_latch',
5151
'wait/synch/rwlock/innodb/dict_operation_lock',
52+
'wait/synch/rwlock/innodb/trx_rseg_latch',
5253
'wait/synch/rwlock/innodb/trx_purge_latch')
5354
ORDER BY event_name;
5455

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ mysql_pfs_key_t fil_space_latch_key;
595595
mysql_pfs_key_t trx_i_s_cache_lock_key;
596596
mysql_pfs_key_t trx_purge_latch_key;
597597
mysql_pfs_key_t lock_latch_key;
598+
mysql_pfs_key_t trx_rseg_latch_key;
598599

599600
/* all_innodb_rwlocks array contains rwlocks that are
600601
performance schema instrumented if "UNIV_PFS_RWLOCK"
@@ -609,6 +610,7 @@ static PSI_rwlock_info all_innodb_rwlocks[] =
609610
{ &trx_i_s_cache_lock_key, "trx_i_s_cache_lock", 0 },
610611
{ &trx_purge_latch_key, "trx_purge_latch", 0 },
611612
{ &lock_latch_key, "lock_latch", 0 },
613+
{ &trx_rseg_latch_key, "trx_rseg_latch", 0 },
612614
{ &index_tree_rw_lock_key, "index_tree_rw_lock", PSI_RWLOCK_FLAG_SX }
613615
};
614616
# endif /* UNIV_PFS_RWLOCK */

storage/innobase/include/srw_lock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ class srw_lock_impl
505505
}
506506
bool rd_lock_try() { return lock.rd_lock_try(); }
507507
bool wr_lock_try() { return lock.wr_lock_try(); }
508+
void lock_shared() { return rd_lock(SRW_LOCK_CALL); }
509+
void unlock_shared() { return rd_unlock(); }
508510
#ifndef SUX_LOCK_GENERIC
509511
/** @return whether any lock may be held by any thread */
510512
bool is_locked_or_waiting() const noexcept

storage/innobase/include/trx0rseg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t
8686
/** tablespace containing the rollback segment; constant after init() */
8787
fil_space_t *space;
8888
/** latch protecting everything except page_no, space */
89-
srw_spin_lock_low latch;
89+
srw_spin_lock latch;
9090
/** rollback segment header page number; constant after init() */
9191
uint32_t page_no;
9292
/** length of the TRX_RSEG_HISTORY list (number of transactions) */

storage/innobase/include/univ.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,5 +577,6 @@ extern mysql_pfs_key_t index_tree_rw_lock_key;
577577
extern mysql_pfs_key_t index_online_log_key;
578578
extern mysql_pfs_key_t trx_sys_rw_lock_key;
579579
extern mysql_pfs_key_t lock_latch_key;
580+
extern mysql_pfs_key_t trx_rseg_latch_key;
580581
# endif /* UNIV_PFS_RWLOCK */
581582
#endif /* HAVE_PSI_INTERFACE */

storage/innobase/trx/trx0purge.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ TRANSACTIONAL_INLINE inline bool TrxUndoRsegsIterator::set_next()
121121
#ifdef SUX_LOCK_GENERIC
122122
purge_sys.rseg->latch.rd_lock();
123123
#else
124-
transactional_shared_lock_guard<srw_spin_lock_low> rg
124+
transactional_shared_lock_guard<srw_spin_lock> rg
125125
{purge_sys.rseg->latch};
126126
#endif
127127
last_trx_no = purge_sys.rseg->last_trx_no();
@@ -367,7 +367,7 @@ static void trx_purge_free_segment(trx_rseg_t *rseg, fil_addr_t hdr_addr)
367367
/* We only need the latch to maintain rseg->curr_size. To follow the
368368
latching order, we must acquire it before acquiring any related
369369
page latch. */
370-
rseg->latch.wr_lock();
370+
rseg->latch.wr_lock(SRW_LOCK_CALL);
371371

372372
buf_block_t* rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr);
373373
buf_block_t* block = trx_undo_page_get(hdr_page_id, &mtr);
@@ -387,7 +387,7 @@ static void trx_purge_free_segment(trx_rseg_t *rseg, fil_addr_t hdr_addr)
387387
rseg->latch.wr_unlock();
388388
mtr.commit();
389389
mtr.start();
390-
rseg->latch.wr_lock();
390+
rseg->latch.wr_lock(SRW_LOCK_CALL);
391391

392392
rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr);
393393

@@ -449,7 +449,7 @@ trx_purge_truncate_rseg_history(
449449

450450
mtr.start();
451451
ut_ad(rseg.is_persistent());
452-
rseg.latch.wr_lock();
452+
rseg.latch.wr_lock(SRW_LOCK_CALL);
453453

454454
buf_block_t* rseg_hdr = trx_rsegf_get(rseg.space, rseg.page_no, &mtr);
455455

@@ -511,7 +511,7 @@ trx_purge_truncate_rseg_history(
511511
}
512512

513513
mtr.start();
514-
rseg.latch.wr_lock();
514+
rseg.latch.wr_lock(SRW_LOCK_CALL);
515515

516516
rseg_hdr = trx_rsegf_get(rseg.space, rseg.page_no, &mtr);
517517

@@ -638,7 +638,7 @@ TRANSACTIONAL_TARGET static void trx_purge_truncate_history()
638638
#ifdef SUX_LOCK_GENERIC
639639
rseg.latch.rd_lock();
640640
#else
641-
transactional_shared_lock_guard<srw_spin_lock_low> g{rseg.latch};
641+
transactional_shared_lock_guard<srw_spin_lock> g{rseg.latch};
642642
#endif
643643
ut_ad(rseg.skip_allocation());
644644
if (rseg.is_referenced())
@@ -849,7 +849,7 @@ static void trx_purge_rseg_get_next_history_log(
849849

850850
mtr.start();
851851

852-
purge_sys.rseg->latch.wr_lock();
852+
purge_sys.rseg->latch.wr_lock(SRW_LOCK_CALL);
853853

854854
ut_a(purge_sys.rseg->last_page_no != FIL_NULL);
855855

@@ -901,7 +901,7 @@ static void trx_purge_rseg_get_next_history_log(
901901

902902
mtr.commit();
903903

904-
purge_sys.rseg->latch.wr_lock();
904+
purge_sys.rseg->latch.wr_lock(SRW_LOCK_CALL);
905905

906906
purge_sys.rseg->last_page_no = prev_log_addr.page;
907907
purge_sys.rseg->set_last_commit(prev_log_addr.boffset, trx_no);

storage/innobase/trx/trx0rec.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ trx_undo_report_row_operation(
21292129
mtr.set_log_mode(MTR_LOG_NO_REDO);
21302130
}
21312131

2132-
rseg->latch.wr_lock();
2132+
rseg->latch.wr_lock(SRW_LOCK_CALL);
21332133
trx_undo_free_last_page(undo, &mtr);
21342134
rseg->latch.wr_unlock();
21352135

storage/innobase/trx/trx0rseg.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void trx_rseg_t::destroy()
380380

381381
void trx_rseg_t::init(fil_space_t *space, uint32_t page)
382382
{
383-
latch.init();
383+
latch.SRW_LOCK_INIT(trx_rseg_latch_key);
384384
ut_ad(!this->space);
385385
this->space= space;
386386
page_no= page;

storage/innobase/trx/trx0sys.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ uint32_t trx_sys_t::history_size()
212212
uint32_t size= 0;
213213
for (auto &rseg : rseg_array)
214214
{
215-
rseg.latch.rd_lock();
215+
rseg.latch.rd_lock(SRW_LOCK_CALL);
216216
size+= rseg.history_size;
217217
}
218218
for (auto &rseg : rseg_array)
@@ -228,7 +228,7 @@ bool trx_sys_t::history_exceeds(uint32_t threshold)
228228
size_t i;
229229
for (i= 0; i < array_elements(rseg_array); i++)
230230
{
231-
rseg_array[i].latch.rd_lock();
231+
rseg_array[i].latch.rd_lock(SRW_LOCK_CALL);
232232
size+= rseg_array[i].history_size;
233233
if (size > threshold)
234234
{

0 commit comments

Comments
 (0)