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

Improve BSON decoding in ByteBufferBsonInput

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Performance
    • None
    • Java Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Based on findings from the JAVA-5814, several improvements can be made to increase the efficiency of BSON decoding. These include reducing unnecessary allocations, avoiding redundant operations, and improving how data is read and processed.

      Scope of Optimizations:

      • Bulk scan for null terminators to reduce per-byte overhead when reading CStrings.
      • Avoid unnecessary String copying where possible during value decoding.
      • Eliminate redundant calls to expensive methods (e.g., ByteBuffer.position()) when the value is already known or cached.
      • Use a temporary scratch buffer to avoid allocating new memory and triggering zero-initialization on each read.  This also reduces GC pressure.

      These changes are expected to improve BSON decoding throughput, especially in high-volume read scenarios.

            Assignee:
            slav.babanin@mongodb.com Slav Babanin
            Reporter:
            slav.babanin@mongodb.com Slav Babanin
            Nathan Xu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: