You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns another Iterable that is potentially iterated in parallel, with a
82
80
given batch size and degree of parallelism.
83
81
84
82
The order of elements is preserved.
85
83
86
84
say ([1..100].hyper.map({ $_ +1 }).list);
87
85
86
+
Use hyper in situations where it is OK to do the processing of items in parallel, and the output order should be kept relative to the input order. See C<race> for situations where items are processed in parallel and the output order does not matter.
87
+
88
+
=head3options degree and batch
89
+
90
+
The degree option (short for "degree of parallelism") configures how many parallel workers should be started. To limit the processing to 4 cores, pass :4degree to the hyper or race methods.
91
+
Note that in some cases choosing of a degree higher than the available CPU cores can make sense. For example I/O bound work or latency-heavy tasks like web crawling.
92
+
93
+
The batch size option configures the number of items sent to a given parallel worker at once.
94
+
It allows for making a throughput/latency trade-off. If for example an operation is long running per item, and you need the first results as soon as possible, set it to 1. That means, every parallel worker gets 1 item to process, and reports the result as soon as possible. In consequence, the overhead for inter-thread communication is maximised.
95
+
In the other extreme, if you have 1000 items to process and 10 workers, and you give every worker a batch of 100 items, you will incur minimal overhead for dispatching the items, but you will only get the first results when 100 items are processed by the fastest worker. (For hyper, when the worker getting the first batch returns.) Also, if not all items take the same amount of time to process, you might run into the situation where some workers are already done and sit around without being able to help with the remaining work.
96
+
In situations where not all items take the same time to process, and you don't want too much inter-thread communication overhead, picking a number somewhere in the middle makes sense. Your aim might be to keep all workers about evenly busy to make best use of the resources available.
97
+
98
+
99
+
B«L<Blog post on the semantics of hyper and race|https://6guts.wordpress.com/2017/03/16/considering-hyperrace-semantics/>»
Returns another Iterable that is potentially iterated in parallel, with a
97
108
given batch size and degree of parallelism (number of parallel workers).
98
109
99
110
Unlike C<hyper>, C<race> does not preserve the order of elements.
100
111
101
112
say ([1..100].race.map({ $_ +1 }).list);
102
113
114
+
Use race in situations where it is OK to do the processing of items in parallel, and the output order does not matter. See C<hyper> for situations where you want items processed in parallel and the output order should be kept relative to the input order.
115
+
116
+
B«L<Blog post on the semantics of hyper and race|https://6guts.wordpress.com/2017/03/16/considering-hyperrace-semantics/>»
117
+
118
+
See C<hyper> for an explanation of :$batch and :$degree.
0 commit comments