Skip to content

FastFutures and FastFuture Pooling

johnmcclean-aol edited this page Sep 9, 2015 · 2 revisions

FastFuture

As of simple-react v0.99.1, we've replaced JDK CompletableFutures in LazyFutureStreams with a custom Future implementation that is highly optimized for our use case, in particularly this Future predefines an immutable execution pipeline for a Stream once and shares it across Futures. This can increase throughput in a LazyFutureStream by over 2.5 times compared with previous versions. Our simple benchmark for throughput increased from 330 million identity functions applied to just over 800 million identity functions applied.

FastFuture pooling

For large long running Streams it is possible to configure LazyFutureStreams to reuse Future instances. This in turn decreases GC impact for an application, whereas in previous versions of simple-react throughput fell significantly from ~330 million identity functions per second to less than half that, for continuous processing with v0.99.1, throughput remains remarkably healthy at ~750 million identity functions applied per second (compared with short-burst capacity of just over 800 million per second).

FastFuture Object pooling is available as an operator on the LazyReact builder and is off by default.

LazyReact lazy = LazyReact.parallel(10)
				.objectPoolingOn()
				.autoOptimize();
lazy.range(0,2_000_000_000)
				.map(this::loadById)
				.map(this::process)
				.forEach(this::save);
Clone this wiki locally