EV::Future

Minimalist and high-performance async control flow for Perl's EV event loop, implemented in XS for maximum speed and minimal overhead.

Project Overview

EV::Future provides three control flow primitives:

All three are implemented in C (XS) to offload task management and callback handling, ensuring low latency and high throughput.

Technologies

Building and Running

Prerequisites

Build Commands

perl Makefile.PL
make

Running Tests

make test
# OR
prove -b t/

Cleaning Up

make clean

Benchmarks

1000 synchronous tasks x 5000 iterations (bench/comparison.pl):

Parallel (iterations/sec)

| Module | Rate | |--------|-----:| | EV::Future (unsafe) | 4,386 | | EV::Future (safe) | 2,262 | | AnyEvent cv (begin/end) | 1,027 | | Future::XS (wait_all) | 982 | | Promise::XS (all) | 32 |

Parallel limit=10 (iterations/sec)

| Module | Rate | |--------|-----:| | EV::Future (unsafe) | 4,673 | | EV::Future (safe) | 2,688 | | Future::Utils fmap_void | 431 |

Series (iterations/sec)

| Module | Rate | |--------|-----:| | EV::Future (unsafe) | 5,000 | | AnyEvent cv (stack-safe) | 3,185 | | EV::Future (safe) | 2,591 | | Future::XS (chain) | 893 | | Promise::XS (chain) | 809 |

Safe mode allocates a per-task CV for double-call protection and wraps each dispatch in G_EVAL. Unsafe mode reuses a single shared CV and skips G_EVAL, roughly doubling throughput.

To run benchmarks:

perl -Mblib bench/benchmark.pl
perl -Mblib bench/comparison.pl

Examples

Practical examples are provided in the eg/ directory:

To run examples:

perl -Ilib eg/curl_parallel.pl                    # requires AnyEvent::YACurl
perl -Ilib eg/redis_parallel.pl                   # requires EV::Hiredis + Redis
perl -Ilib eg/etcd_series.pl                      # requires EV::Etcd + etcd

Development Conventions

XS Implementation

Testing

Coding Style