GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - morganchristiansson/parallel: Ruby: parallel processing made simple and fast

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

255 Commits
255 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
spec
spec
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
Rakefile
Rakefile
 
 
Readme.md
Readme.md
 
 
VERSION
VERSION
 
 
parallel.gemspec
parallel.gemspec
 
 

Repository files navigation

Run any code in parallel Processes(> use all CPUs) or Threads(> speedup blocking operations).
Best suited for map-reduce or e.g. parallel downloads/uploads.

Install

sudo gem install parallel

Usage

# 2 CPUs -> work in 2 processes (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| ... } or each_with_index or map_with_index

Processes

  • Speedup through multiple CPUs
  • Speedup for blocking operations
  • Protects global data
  • Extra memory used ( very low on REE through copy_on_write_friendly )
  • Child processes are killed when your main process is killed through Ctrl+c or kill -2

Threads

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

Processes/Threads are workers, they grab the next piece of work when they finish

Tips

  • [ActiveRecord] ActiveRecord::Base.connection.reconnect! inside the parallel block prevents errors
  • [Benchmark/Test] Disable threading/forking with :in_threads => 0 or :in_processes => 0, great to test performance or to debug parallel issues

TODO

  • JRuby / Windows support <-> possible ?

Authors

Contributors

  • Przemyslaw Wroblewski
  • TJ Holowaychuk
  • Masatomo Nakano
  • Fred Wu
  • mikezter
  • Jeremy Durham
  • Nick Gauthier
  • Andrew Bowerman
  • Byron Bowerman
  • Mikko Kokkonen
  • brian p o'rourke
  • [Norio Sato]

Michael Grosser
[email protected]
License: MIT
Flattr

About

Ruby: parallel processing made simple and fast

Resources

Readme
Activity

Stars

3 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.