AnyEvent-Fork-Pool
view release on metacpan or search on metacpan
Setting this low improves latency. For example, at C<1>, every job that
is sent to a worker is sent to a completely idle worker that doesn't run
any other jobs. The downside is that throughput is reduced - a worker that
finishes a job needs to wait for a new job from the parent.
The default of C<2> is usually a good compromise.
=item start => $seconds (default: 0.1)
When there are fewer than C<idle> workers (or all workers are completely
busy), then a timer is started. If the timer elapses and there are still
jobs that cannot be queued to a worker, a new worker is started.
This sets the minimum time that all workers must be busy before a new
worker is started. Or, put differently, the minimum delay between starting
new workers.
The delay is small by default, which means new workers will be started
relatively quickly. A delay of C<0> is possible, and ensures that the pool
will grow as quickly as possible under load.
Array::Heap::splice_heap_idx @pool, $proc->[1]
if defined $proc->[1];
@$proc = 0; # tell others to leave it be
};
$want_start = sub {
undef $stop_w;
$start_w ||= AE::timer $start, $start, sub {
if (($nidle < $idle || @queue) && @pool < $max) {
$start_worker->();
$scheduler->();
} else {
undef $start_w;
}
};
};
$want_stop = sub {
$stop_w ||= AE::timer $stop, $stop, sub {
$stop_worker->($pool[0])
if $nidle;
undef $stop_w
if $nidle <= $idle;
};
};
$scheduler = sub {
if (@queue) {
Setting this low improves latency. For example, at 1, every
job that is sent to a worker is sent to a completely idle
worker that doesn't run any other jobs. The downside is that
throughput is reduced - a worker that finishes a job needs
to wait for a new job from the parent.
The default of 2 is usually a good compromise.
start => $seconds (default: 0.1)
When there are fewer than "idle" workers (or all workers are
completely busy), then a timer is started. If the timer
elapses and there are still jobs that cannot be queued to a
worker, a new worker is started.
This sets the minimum time that all workers must be busy
before a new worker is started. Or, put differently, the
minimum delay between starting new workers.
The delay is small by default, which means new workers will
be started relatively quickly. A delay of 0 is possible, and
ensures that the pool will grow as quickly as possible under
( run in 3.109 seconds using v1.01-cache-2.11-cpan-49f99fa48dc )