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

22% reduction of sizeof(dict_index_t) is easily possible

    XMLWordPrintable

Details

    • Related to performance

    Description

      While reviewing MDEV-37070, I paid attention to sizeof(dict_index_t). It turns out to contain quite a bit of bloat. I experimented with GDB:

      ptype/o dict_index_t
      

      and came up with the following tweaks:

      1. Reduce the size of trx_id_offset from 12 to 9 bits. If there is a fixed-length PRIMARY KEY that is longer than 511 bytes, let us treat it as variable-length. Extremely long primary keys are a bad idea anyway.
      2. Move uncommitted and n_core_null_bytes right after trx_id_offset to completely fill the 32-bit unsigned word.
      3. Move cached and to_be_dropped after n_def to fill the word: 10+10+10+1+1=32.
      4. Change ahi::ref_count (the number of covered index leaf pages in the buffer pool) from size_t to uint32_t. The number of index pages must fit in that quantity, because all pages of an index must be in the same tablespace, and the page numbers are 32-bit.
      5. Remove zip_pad_info_t::mutex and use dict_table_t::lock_latch instead. This is only needed in the rarely invoked functions dict_index_zip_success() and dict_index_zip_failure().
      6. Replace search_info with a union of ahi and some rtr fields. Note that root_guess must be kept outside the union; it’s also being used for accessing SPATIAL INDEX pages.
      7. Inside the union, replace rtr_info_track_t with an intrusive list of rtr_info. Use dict_table_t::lock_latch instead of a dedicated mutex.

      With these small tweaks, we can shrink sizeof(dict_index_t) from 288 (0x120) to 224 (0xe0) bytes, saving 22%, not counting the savings for SPATIAL INDEX.

      Attachments

        Issue Links

          Activity

            People

              alessandro.vetere Alessandro Vetere
              marko Marko Mäkelä
              Votes:
              1 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.