[erlang-questions] Process pool map/3 implementation

Parnell Springmeyer ixmatus@REDACTED
Wed Jul 20 07:08:00 CEST 2011

Hash: SHA1

For a work project I have a large list (thousands of items) to process
and at first built a "pmap" implementation as per Joe's book until I
found the plists module (which is awesome btw).

There is one glaring issue with the list -> subdivide -> spawn x
processes for n sublist items strategy; if an item in the sublist takes
longer than all the other items it blocks the entire resource allotment
until it is done.

In most cases, the plists/pmap implementation works just fine because
the items in the list probably don't take more than a few milliseconds
to map the fun over. However, it does become an issue when that is not
the case.

So, I figured the next best strategy would be to implement a process
pool since it would allow for slow running processes to continue their
work while finished processes can die and new processes spawned into the
pool ready for work - so none of the resources are sitting idle.

Right now, my module isn't nearly as feature-complete as the plists
module is - this is only a drop in replacement for map. Please submit
your criticisms and comments to me at this address.

You may find the code on BitBucket: https://bitbucket.org/ixmatus/ppool

- -- 
Parnell "ixmatus" Springmeyer (http://ixmat.us)
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org


More information about the erlang-questions mailing list