AnyEvent-Fork-Pool
view release on metacpan or search on metacpan
and before the callback is invoked causes undefined behaviour.
=cut
=item $cpus = AnyEvent::Fork::Pool::ncpu [$default_cpus]
=item ($cpus, $eus) = AnyEvent::Fork::Pool::ncpu [$default_cpus]
Tries to detect the number of CPUs (C<$cpus> often called CPU cores
nowadays) and execution units (C<$eus>) which include e.g. extra
hyperthreaded units). When C<$cpus> cannot be determined reliably,
C<$default_cpus> is returned for both values, or C<1> if it is missing.
For normal CPU bound uses, it is wise to have as many worker processes
as CPUs in the system (C<$cpus>), if nothing else uses the CPU. Using
hyperthreading is usually detrimental to performance, but in those rare
cases where that really helps it might be beneficial to use more workers
(C<$eus>).
Currently, F</proc/cpuinfo> is parsed on GNU/Linux systems for both
C<$cpus> and C<$eus>, and on {Free,Net,Open}BSD, F<sysctl -n hw.ncpu> is
used for C<$cpus>.
Example: create a worker pool with as many workers as CPU cores, or C<2>,
if the actual number could not be determined.
Note that there can be considerable time between calling this method
and the call actually being executed. During this time, the
parameters passed to this function are effectively read-only -
modifying them after the call and before the callback is invoked
causes undefined behaviour.
$cpus = AnyEvent::Fork::Pool::ncpu [$default_cpus]
($cpus, $eus) = AnyEvent::Fork::Pool::ncpu [$default_cpus]
Tries to detect the number of CPUs ($cpus often called CPU cores
nowadays) and execution units ($eus) which include e.g. extra
hyperthreaded units). When $cpus cannot be determined reliably,
$default_cpus is returned for both values, or 1 if it is missing.
For normal CPU bound uses, it is wise to have as many worker
processes as CPUs in the system ($cpus), if nothing else uses the
CPU. Using hyperthreading is usually detrimental to performance, but
in those rare cases where that really helps it might be beneficial
to use more workers ($eus).
Currently, /proc/cpuinfo is parsed on GNU/Linux systems for both
$cpus and $eus, and on {Free,Net,Open}BSD, sysctl -n hw.ncpu is used
for $cpus.
Example: create a worker pool with as many workers as CPU cores, or
2, if the actual number could not be determined.
( run in 0.243 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )