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

trx_t::autoinc_locks causes unnecessary dynamic memory allocation

    XMLWordPrintable

Details

    Description

      The data structure trx_t::autoinc_locks is of type ib_vector_t*. It is unconditionally allocated in trx_create() even when no AUTO_INCREMENT locks will be used by the transaction, even for read-only transactions.

      We had better make use of a template that was introduced in MDEV-30289:

      small_vector<lock_t*, 4> autoinc_locks;
      

      The data elements are trivially assignable and allocated separately; the first 8 table locks of a transaction would use the trx->lock.table_pool in lock_table_create(). Any data-modifying transaction will typically also require a table IX lock in addition to the auto-increment lock. That is why 4 would be a reasonable fixed size.

      Only if a transaction involved more than 4 auto-increment locks, we would dynamically allocate a larger vector, similar to how the 16-element mtr_t::m_memo works.

      Attachments

        Issue Links

          Activity

            People

              debarun Debarun Banerjee
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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