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

mtr_t::m_memo is causing frequent memory heap operations

    XMLWordPrintable

Details

    Description

      As part of fixing MDEV-29603, the implementation of mtr_t::m_memo was changed to std::vector. According to some performance test analysis by wlad, that caused some performance regression due to more frequent memory heap allocation.

      Function Name   Total CPU [unit, %] Self CPU [unit, %]  Module
      | - [External Call]  WriteFile    9928 (7.55%)    9928 (7.55%)    kernelbase
      | - [External Call]_malloc_base   5897 (4.49%)    5897 (4.49%)    ucrtbase
      | - int __cdecl MYSQLparse(class THD *)   8604 (6.55%)    4392 (3.34%)    server
      | - unsigned short * __cdecl rec_get_offsets_func(unsigned char const *,struct dict_index_t const *,unsigned short *,unsigned __int64,unsigned __int64,struct mem_block_info_t * *)   6175 (4.70%)    4384 (3.34%)    server
      | - bool __cdecl page_cur_search_with_match(struct dtuple_t const *,enum page_cur_mode_t,unsigned __int64 *,unsigned __int64 *,struct page_cur_t *,struct rtr_info *) 11572 (8.80%)   3397 (2.58%)    server
      | - struct buf_block_t * __cdecl buf_page_get_low(class page_id_t,unsigned __int64,unsigned __int64,struct buf_block_t *,unsigned __int64,struct mtr_t *,enum dberr_t *)  8014 (6.10%)    3048 (2.32%)    server
      | - [External Call]  _free_base   2852 (2.17%)    2852 (2.17%)    ucrtbase
      | - [External Call] ReadFile  2030 (1.54%)    2030 (1.54%)    kernelbase
      

      Ideally, we would want to use a collection that implements something similar to the "small string optimization" of std::string. That is, we should allocate some memory for small mtr_t::m_memo as part of m_mtr itself. Only if too many objects are being latched in the mini-transaction (say, when very deep index trees are being accessed) we should need heap-based allocation.

      LLVM includes SmallVector, which is exactly what we would seem to need. It is also available in Boost as small_vector.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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