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

Inlined BufBuilder's grow_reallocate() method consumes a lot of stack space

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL

      When various append methods of BSONObjBuilder get inlined they all sooner or later inline grow_reallocate().

      The grow_reallocate has std::stringstream variable on a local stack (~400 bytes). All that space is allocated in the caller stack frame when the callee is inlined. 

      There is code that calls append many times and each inlined call incurs 400 bytes penalty. It quickly adds up to huge stack frames.

            Assignee:
            martin.neupauer@mongodb.com Martin Neupauer
            Reporter:
            martin.neupauer@mongodb.com Martin Neupauer
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: