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

BSONArrayBuilder::fill creates and destroys multiple std::string operations on every call

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.5.6
    • Fix Version/s: 1.5.7
    • Component/s: Internal Client
    • Labels:
      None
    • Environment:
      all

      Description

      BSONArrayBuilder::fill is declared as follows:

      void fill( const StringData& name )

      { char *r; int n = strtol( name.data(), &r, 10 ); uassert( 13048, (string)"can't append to array using string field name [" + name.data() + "]" , !*r ); while( _i < n ) append( nullElt() ); }

      That 'uassert' call ends up constructing a temporary string, appending to it, and then passing it by value to uassert, all to determine that r is not NULL in the vast majority of cases. From what i can tell in bson.h, the uassert call is not conditional on a debug build, or something similar.

      Removing the uassert dramatically improves the performance of adding elements to a BSON array.

        Attachments

          Activity

            People

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            acm Andrew Morrow
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: