[MDEV-22544]  Inconsistent and Incorrect rw-lock stats Created: 2020-05-13  Updated: 2020-05-19  Resolved: 2020-05-15

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4.12, 10.5.3
Fix Version/s: 10.5.4, 10.2.33, 10.3.24, 10.4.14

Type: Bug Priority: Minor
Reporter: Krunal Bauskar Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None


 Description   
  • Inconsistent and Incorrect rw-lock stats
  • There are multiple inconsistency and incorrect way in which rw-lock
    stats are calculated.
  • shared rw-lock stats:
  • "rounds" counter is incremented only once for N rounds done in spin-cycle.
  • all rw-lock stats:
  • if the spin-cycle is short-circuited then attempts are re-counted.
    [if spin-cycle is interrupted, before it completes srv_n_spin_wait_rounds
    (default 30) rounds, spin_count (renamed to spin_round_count for better
    clarity) is incremented to consider this.
    if thread resumes spin-cycle (due to unavailability of the locks)
    and is again interrupted or completed spin_count (spin_round_count) is
    again incremented with the total count, failing to adjust the previous
    attempt increment].
  • s/x rw-lock stats:
  • spin_loop counter is not incremented at-all instead it is projected
    as 0 (in show engine output) and division to calculate spin-round per
    spin-loop is adjusted.
  • as per the original semantics spin_loop counter should be incremented
    once per spin_loop execution.
  • sx rw-lock stats:
  • sx locks increment spin_loop counter but instead of incrementing it once
    for spin_loop invocation it does it multiple times based on how many
    time spin_loop flow is repeated for same instance post os-wait.


 Comments   
Comment by Krunal Bauskar [ 2020-05-13 ]

Patch for it could be found here.
https://github.com/mysqlonarm/server/commit/6b21ce184ecc24a03a552eb9b0aad89fc1995be4

Comment by Marko Mäkelä [ 2020-05-13 ]

krunalbauskar, thank you! A few notes:

  • We try to apply changes to the earliest affected version. I believe that the change should apply to MariaDB 10.2. But your patch is based on 10.5. Can you please rebase it to 10.2?
  • Coding style: I prefer to limit the scope of variables. Would ulint j = i; work?
  • Can you please open a pull request?
Comment by Krunal Bauskar [ 2020-05-14 ]

PR submitted: https://github.com/MariaDB/server/pull/1535 (based on 10.2)

Local mtr testing done found to be working (except the known failured re-check it with the http://buildbot.askmonty.org/buildbot/grid?branch=10.2)

Output
-----------

without patch
=============
OS WAIT ARRAY INFO: reservation count 1905259
OS WAIT ARRAY INFO: signal count 424327
RW-shared spins 0, rounds 18226, OS waits 2732
RW-excl spins 0, rounds 11096957, OS waits 178606
RW-sx spins 3204, rounds 83720, OS waits 1918
Spin rounds per wait: 18226.00 RW-shared, 11096957.00 RW-excl, 26.13 RW-sx

with patch
==========
OS WAIT ARRAY INFO: reservation count 1969248
OS WAIT ARRAY INFO: signal count 445870
RW-shared spins 13515, rounds 121096, OS waits 2880
RW-excl spins 1363552, rounds 10484920, OS waits 181852
RW-sx spins 3303, rounds 87907, OS waits 1994
Spin rounds per wait: 8.96 RW-shared, 7.69 RW-excl, 26.61 RW-sx


  • Numbers are not directly comparable but just for references
Generated at Thu Feb 08 09:15:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.