Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby: parallel processing made simple and fast

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 rdoc
Octocat-spinner-32 spec
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 parallel.gemspec
README.markdown

Run any kind of code in parallel Processes or Threads, to speedup computation by factor #{your_cpus} X.

  • Child processes are killed when your main process is killed through Ctrl+c or kill -2
  • Processes/threads are workers, they grab the next piece of work when they finish

Install

sudo gem install parallel

Usage

Processes

  • Speedup through multiple CPUs
  • Speedup for blocking operations
  • Protects global data
  • Extra memory used

Threads

  • Speedup for blocking operations
  • Global data can be modified
  • No extra memory used

    2 CPUs -> finished after 2 runs (a,b + c)

    results = Parallel.map(['a','b','c']) do |one_letter| expensive_calculation(letter) end

    3 Processes -> finished after 1 run

    results = Parallel.map(['a','b','c'], :in_processes=>3){|one_letter| ... }

    3 Threads -> finished after 1 run

    results = Parallel.map(['a','b','c'], :in_threads=>3){|one_letter| ... }

Same can be done with each Parallel.each(['a','b','c']){|one_letter| ... }

TODO

  • JRuby / Windows support <-> possible ?

Authors

Contributors (alphabetical)

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.