[SERVER-1489] BSONArrayBuilder::fill creates and destroys multiple std::string operations on every call Created: 26/Jul/10 Updated: 12/Jul/16 Resolved: 26/Jul/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 1.5.6 |
| Fix Version/s: | 1.5.7 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Andrew Morrow (Inactive) | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
all |
||
| Participants: |
| 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. |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 26/Jul/10 ] |
|
Wow, that was fast! Had you independently noticed this and already started on it? Anyway, thanks for the quick fix. |
| Comment by Eliot Horowitz (Inactive) [ 26/Jul/10 ] |
|
i already just about finished this |