vert.x
vert.x copied to clipboard
Reduce InboundBuffer pending queue's allocation pressure
InboundBuffer's allocation create 16 pending entries by default while it could delay it when the initial size information is available. This change is going to lazy allocate it: it's less elegant due to the many null checks, but it's effective to reduce allocations in the hot paths. Subsequent allocations will make uses of the ArrayDeque enlarging strategy but starting with a much lower number (double capacity, but starting from 1 instead of 16)
This is screen from JFR allocation recording of Techempower's plaintext, showing this as one of the top allocators
in which case does it improve allocation ?
In the cases of 0 -> 15 pending elements, but the most benefit come when there are none or very few . ArrayDeque is not like ArrayList that defer the real allocation: it allocates 16 elements by default, causing useless garbage to be created
@vietj ping on this bud
thanks for the contrib @franz1981