haskell - Parallel processing in conduit flow -


I really like the concept of a conduit / pipes to implement the operation for a streaming IO source. I'm interested in building tools that work on very large log files, an easy way to write a parallel code of attraction from Pisson / Ruby to Haskel, but I'm not getting any documents about it. How can I install a drain flow which reads lines from a file and works in parallel (i.e. with 8 cores, it should read eight lines, and be handed over to eight different threads to process them, And then to be re-collected etc.), possibly as small as the "function" ...

Alternatively, it can be noted that the lines need to be added in sequence Have Or not, if it could affect the speed of the process?

I am sure that it would be possible to use ideas from parallel Haskell's book to spray them together, but it seems that uniform work should be performed in the middle of a drain workflow Too easy? Petr Pudlák, in his comment as an example of "internal similarity", consider the function (

I Pipes , but can be easily implemented with conduit ):

  Import control. Mono import control. Lens (See) Import Control Concentrator. ACICNC import pipes import qualified pipe. Group G imports as a valid control. L concprod :: INT - & gt; (A -> Io B) - & gt; Manufacturer is an IoR - & gt; Producer BIO RConprod Groupis Action Producer = L. Peerly G. Faldus L. List (see (G. Chanchu Group Group) producer) & gt; - & gt; Forever (wait> gt; = .ioi map, expected action> gt; = mapM G.yield)  

This function takes the form of criteria for a group size , A verb that we want to run for each a of value, and creator of a value

this one The new manufacturer returns internally, the manufacturer codifies a values ​​, in the norms of them; Processes the process, and produces the results one by one.

Use the code Pipes.Group to originally "split" the "sub-creator" size to groupize and then each sub-productive To "fold", Control.Foldl in a list.

For more sophisticated functions, you can convert to asynchronous channels provided by pipe-concurrency or stm-conduit . But you get out of the parts of the "single pipeline" worldview of vanilla pipes / rivers.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -