vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

ListenerArray throuhput and allocation improvements

Open tsegismont opened this issue 3 years ago • 1 comments

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 ListenerArray extending ArrayList and creating a list with the default capacity (10)
  • in many cases, futures get two listeners (onSuccess/onFailure)

tsegismont avatar Sep 20 '22 08:09 tsegismont

cc @franz1981 (in case you got time to review this short PR)

tsegismont avatar Sep 20 '22 08:09 tsegismont