-
Type:
Task
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Java Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
In BsonBinaryWriter, array element field names are currently generated using Integer.toString(index) on each write. This creates new string instances repeatedly during BSON array serialization, which can be inefficient for large arrays and adds unnecessary GC pressure.
To improve performance, we should introduce a cache of precomputed string representations for commonly used array indexes (e.g., 0 to 255). These cached values can be reused when writing array element names, avoiding repetitive allocations.
Rationale:
- Reduces memory allocations and GC overhead when writing large arrays
This change will benefit workloads involving large BSON arrays.