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

Change MEM_ROOT allocation sizes to reduse calls to malloc() and avoid memory fragmentation

Details

    • Task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Most of the MariaDB memory allocations goes through the MEM_ROOT interface.
      MEM_ROOT primary object has been to reduce calls to malloc() by storing allocations in thread-local linked memory areas that are all freed at once.

      This task has two purposes:

      • To reduce malloc() calls even further by allocation slightly bigger blocks in some areas where the initial block size has been found to be too small.
      • Always allocate the internal blocks in power of 2, which is something that will help reduce memory fragmentation with all (?) known memory allocators.

      This should reduce memory fragmentation as malloc() does not anymore have to split it internal blocks in two, which can happen for example if one allocates a block of 8197 bytes. In this case the malloc() will use a block of size 16384 and give 8197 bytes to MEM_ROOT while using the 8195 byte block for other things. When the 8971 byte block is released, it is very unlikely it can be merged together to the 8195 byte block (as it probably used for other things) with results in memory fragmentation.

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              monty Michael Widenius
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.