-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
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.