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

Improve BSON decoding in ByteBufferBsonInput

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 5.5.0
    • Affects Version/s: None
    • Component/s: Performance
    • None
    • Java Drivers
    • Not Needed
    • 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:
              Resolved: