Slide 8
Slide 8 text
Design of PelemayFp
• PelemayFp is implemented using only Elixir, like Flow.
• In Flow, the order of the list after computation is not guaranteed,
while in PelemayFp, the order of the list is guaranteed because it is sorting while collecting and merging.
• PelemayFp consists of the following modules:
• PelemayFp, which is the facade module, and which provides map and map_chunk functions;
• PelemayFp.ParallelSplitter, which provides the split function that decides a given enumerable into a chunk list whose size equals to or is less than the given threshold,
with spawning each process corresponding to the chunked list, and the range function that returns the range from the number of the chunk minus 1 to 0.
The reason that the range is descending is that PelemayFp.ParallelBinaryMerger will receive fragments of the given list at the best execution speed if it is in reverse order,
because a list in Elixir is immutable;
• PelemayFp.Sub, which is inner and undocumented, and which wraps the difference of map and map_chunk;
• PelemayFp.ParallelBinaryMerger, which receives a given consecutive list of tuples of a Range, count and a list, or an exit or dying message from the monitored process
and merges it into a result, and send it;
• PelemayFp.BinaryMerger, which inserts a given consecutive list of tuples of a Range, count and a list into another one;
• PelemayFp.Merger, which merges two consecutive list of tuples of a Range, count and a list.
• Splitting the given list, spawning each worker process, calculating at each worker, collecting the result of workers, and sorting the result are executed in parallel.
• In contrast, Flow with sorting executes them partially in parallel and partially in sequential.
8
© 2021 Susumu Yamazaki