Skip to content

Commit

Permalink
Added limit to number of processes with runf (currently set to 20).
Browse files Browse the repository at this point in the history
  • Loading branch information
Timofey Potapov committed Sep 11, 2024
1 parent 01883b4 commit fa617b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Revision history for e
=================

Added commands: max, min (from List::Util).
Added limit to number of processes with runf (currently set to 20).
Updated pod.

=================
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ This sector includes commands to run asynchronous

It is not entirely clear which method to always use.

`runf` limits to number of action or 20 (whichever is smaller).

`runt` and `runio` have no such limits.

Typically using threads (with `runt`) seems to be fastest.

Some statistics using different run commands:
Expand Down Expand Up @@ -603,6 +607,8 @@ Returns the results.

Takes much overhead to start up!

Will use up to 20 processes.

### runio

Run tasks in parallel using [Mojo::IOLoop](https://metacpan.org/pod/Mojo%3A%3AIOLoop).
Expand Down
10 changes: 9 additions & 1 deletion lib/e.pm
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ This sector includes commands to run asynchronous
It is not entirely clear which method to always use.
C<runf> limits to number of action or 20 (whichever is smaller).
C<runt> and C<runio> have no such limits.
Typically using threads (with C<runt>) seems to be fastest.
Some statistics using different run commands:
Expand Down Expand Up @@ -637,6 +641,8 @@ Returns the results.
Takes much overhead to start up!
Will use up to 20 processes.
=head3 runio
Run tasks in parallel using L<Mojo::IOLoop>.
Expand Down Expand Up @@ -1128,7 +1134,9 @@ sub import {
require Parallel::ForkManager;
}

my $pm = Parallel::ForkManager->new( ~~ @_ );
my $MAX_PROCESSES = 20;
my $processes = ( @_ > $MAX_PROCESSES ) ? $MAX_PROCESSES : @_;
my $pm = Parallel::ForkManager->new( $processes );
my @res;

$pm->run_on_finish(
Expand Down

0 comments on commit fa617b9

Please sign in to comment.