Details
-
Task
-
Status: Resolved
-
Normal
-
Resolution: Won't Fix
-
None
-
None
-
All
-
None
Description
The GrowableByteArrayDataOutput in RAMIndexOutput is currently initialized with a size of 128 bytes. There is no explanation as to why this size was chosen.
The GrowableByteArrayDataOutput does not lazily allocate memory but only ever allocates enough for each write operation. This can lead to a lot of fresh allocations and calls to System.arrayCopy.
Since RAMIndexOutput is used to build the on-disk postings in SAI it is likely that the size of the in-memory array is going to grow considerably more that 128 bytes.
We should investigate changing this initial value to something higher and possibly changing the GrowableByteArrayDataOutput class to allocate in blocks rather than write increments.