-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Performance
-
None
-
Not Needed
Microbenchmark of insert indicates that ~5% of time is spent in IdHoldingBsonWriter#getIdBsonWriter . An analysis of the code shows that in the normal case (when the document contains a simple _id value like an ObjectId), then it's not necessary to even call this method. We should consider optimizing this class to remove unnecessary calls to this method.
The main issue with the method appears to be the creation of a BasicOutputBuffer, which in turns creates a 1K byte array. We generally pool large buffers like this, but this is a case where the pool is not used. So a couple of other options would be to use a pooled buffer here, or dramatically shrink its size by using the constructor which allows it to be specified.