Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4608

Optimize IdHoldingBsonWriter

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • 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.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: