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

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 1.5.6
    • 1.5.7
    • Internal Client
    • None
    • 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

            eliot Eliot Horowitz (Inactive)
            andrew.morrow@mongodb.com Andrew Morrow
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: