Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40408

btr_page_reorganize_low() uses the buffer pool just to obtain a scratch block

    XMLWordPrintable

Details

    • Related to performance
    • Hide
      AI generated: During InnoDB page reorganization (such as compacting records on a page), allocating a temporary scratch block from the buffer pool required acquiring the buffer pool mutex and could cause threads to wait for a free block while holding an exclusive page latch, delaying concurrent readers of the same page. To address this, InnoDB now uses a dedicated, on-demand scratch buffer pool for page reorganization operations, eliminating buffer pool mutex acquisitions and free block waits while exclusive page latches are held. This scratch buffer memory is allocated outside of innodb_buffer_pool_size and is automatically freed when the server is idle or under memory pressure.
      Show
      AI generated: During InnoDB page reorganization (such as compacting records on a page), allocating a temporary scratch block from the buffer pool required acquiring the buffer pool mutex and could cause threads to wait for a free block while holding an exclusive page latch, delaying concurrent readers of the same page. To address this, InnoDB now uses a dedicated, on-demand scratch buffer pool for page reorganization operations, eliminating buffer pool mutex acquisitions and free block waits while exclusive page latches are held. This scratch buffer memory is allocated outside of innodb_buffer_pool_size and is automatically freed when the server is idle or under memory pressure.
    • Q3/2026 Server Maintenance, Q3/2026 Server Development

    Description

      btr_page_reorganize_low() (and page_zip_reorganize()) needs a scratch/temporary block to perform the page reorganization (to compact the records in a page).
      Currently, this block is allocated from the buffer pool and freed at the end of the function.
      This means that the function needs to obtain at least twice the buffer pool mutex to do so.
      In addition, any wait for buffer pool mutex here would be done while holding the page X-latch, further delaying at least any queued reader of the same page.

      Scratch blocks could be carved out of another storage, which I called btr_scratch_pool_t in one experimental commit, that has its own synchronization mechanisms and allow to not pollute the main buffer pool mutex for scratch blocks handling.
      Only users (threads) of the new storage would collide with each other.

      Attachments

        Issue Links

          Activity

            People

              alessandro.vetere Alessandro Vetere
              alessandro.vetere Alessandro Vetere
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 5d Original Estimate - 5d
                  5d
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 5d 3.5h
                  5d 3.5h

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.