Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-60137

Improve Buffer Allocation for Common BSON-related Sizes

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: Query Execution
    • None
    • Fully Compatible
    • QE 2021-10-04, QE 2021-10-18

      Currently, when we are requesting a piece of memory that might contain a BSON object, it usually requires BSONObjMaxUserSize bytes (i.e., 16MB) plus a residual amount of memory for its wrapper data structure, which is BSONObjMaxInternalSize bytes (i.e., 16MB+16KB). Then, we ask the buffer builder to allocate this much memory, it tries to allocate an amount of memory that's a power of two. In this case, it allocates 32MB of memory, which is usually a waste of resources.

      In this ticket, based on the discussions with bernard.gorman, david.storch and redbeard0531, we want to change the buffer builder logic in the grow_reallocate to allocate BSONObjMaxInternalSize bytes if the requested re-allocated amount is anything between BSONObjMaxUserSize and BSONObjMaxInternalSize bytes.

            Assignee:
            mohammad.dashti@mongodb.com Mohammad Dashti (Inactive)
            Reporter:
            mohammad.dashti@mongodb.com Mohammad Dashti (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: