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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.7
    • Affects Version/s: 1.5.6
    • Component/s: Internal Client
    • Labels:
      None
    • Environment:
      all

      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.

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

              Created:
              Updated:
              Resolved: