vert.x
vert.x copied to clipboard
ListenerArray throuhput and allocation improvements
Use our own elements array with small initial size instead of extending ArrayList and using default capacity (10).
Running FutureListenerBenchmark before and after this change shows:
- 30% throughput increase and 15% or 12% memory allocation decrease (per op) when adding 2 or 4 listeners
- 6% throughput increase and 6% memory allocation increase (per op) when adding 6 listeners
- 1.5% throughput decrease and 24% memory allocation increase (per op) when adding 8 listeners
Note that:
- the previous version was tested unchanged, i.e. with
ListenerArrayextendingArrayListand creating a list with the default capacity (10) - in many cases, futures get two listeners (
onSuccess/onFailure)
cc @franz1981 (in case you got time to review this short PR)