Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-15009

Defragment document key+meta (i.e. StoredValue) in addition to Blobs

    XMLWordPrintable

Details

    Description

      During investigation of an unrelated memcached bug (MB-15007) I noticed that of the fragmented jemalloc memory a significant amount of it (75%) was from the 80 byte size class:

      small allocation stats:
        bin  size (B)  regions     pages    allocated    allocated  cur runs         % of small                % of blame         
                       per run   per run        items        bytes           utilization     frag memory (B)                         
       
          0         8      512         1      2381756     19054048      4653    100%      0%            4640       0%
          1        16      256         1         2025        32400       116      7%      0%          442736       0%
          2        32      128         1     10857534    347441088     90002     94%      4%        21207104       3%
          3        48      256         3       305749     14675952      2742     44%      0%        19017744       3%
          4        64       64         1        64371      4119744      1632     62%      0%         2564928       0%
          5        80      256         5     11102416    888193280     67517     64%     11%       494554880      75%
          6        96      128         3         5378       516288        62     68%      0%          245568       0%
          7       112      256         7       494100     55339200      3135     62%      1%        34547520       5%
       
          utilization = allocated / (size * regions_per_run * cur runs)
          % of small  = allocated / total allocated
          frag memory = (size * regions_per_run * cur runs) - allocated
          % of blame  = frag memory / total frag memory
      

      I don't definitively know for sure, but I hypothesise that this is the size class being used for StoredValue objects. Currently the defragmenter only reallocates the Blob part of a document; but there may be value in additionally reallocing the StoredValue (i.e. the document key and metadata).

      This would likely help cases where a large number of documents with a given key size are deleted, and then new documents are allocated with a different key size. In this case the original size class would not be able to be reused, and hence fragmentation could be high in that class.

      My expectation would be that the magnitude of reclaimed memory would be much lower than say the existing Blob defragmentation as keys are typically significantly smaller than values. However for certain use-cases where values are of similar size to the key (and where key sizes vary) this could have noticeable benefit.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              arunkumar Arunkumar Senthilnathan (Inactive)
              drigby Dave Rigby (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty