-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Java Drivers
-
None
-
None
-
None
-
None
-
None
-
None
The current implementation of ByteBufferBsonOutput accesses the active ByteBuf on each write via bufferList.get(index), introducing unnecessary overhead and limiting JIT inlining.
We can optimize this by caching the current buffer in a currentByteBuffer field and updating it only when switching buffers.
Rationale:
- Accessing a field is just a pointer dereference — extremely cheap, especially once JIT-optimized.
- bufferList.get(index) involves bounds checking and method invocation, even for ArrayList.
- While individually cheap, this overhead adds up in tight write loops under high throughput.