All Projects → seantanly → Elixir Paratize

seantanly / Elixir Paratize

Licence: mit
Elixir library providing some handy parallel processing facilities that supports configuring number of workers and timeout.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Elixir Paratize

P tqdm
Parallel processing with progress bars
Stars: ✭ 195 (+680%)
Mutual labels:  parallel-processing
infantry
Run MapReduce in user's browser.
Stars: ✭ 14 (-44%)
Mutual labels:  parallel-processing
Parallel
Parallel processing for PHP based on Amp.
Stars: ✭ 478 (+1812%)
Mutual labels:  parallel-processing
Parallel-NDJSON-Reader
Parallel NDJSON Reader for Python
Stars: ✭ 13 (-48%)
Mutual labels:  parallel-processing
snap
Snap Programming Language
Stars: ✭ 20 (-20%)
Mutual labels:  parallel-processing
mlbgameday
Multi-core processing of 'Gameday' data from Major League Baseball Advanced Media. Additional tools to parallelize large data sets and write them to a database.
Stars: ✭ 37 (+48%)
Mutual labels:  parallel-processing
Pyexpool
Python Multi-Process Execution Pool: concurrent asynchronous execution pool with custom resource constraints (memory, timeouts, affinity, CPU cores and caching), load balancing and profiling capabilities of the external apps on NUMA architecture
Stars: ✭ 149 (+496%)
Mutual labels:  parallel-processing
Fastcore
Python supercharged for the fastai library
Stars: ✭ 565 (+2160%)
Mutual labels:  parallel-processing
future.callr
🚀 R package future.callr: A Future API for Parallel Processing using 'callr'
Stars: ✭ 52 (+108%)
Mutual labels:  parallel-processing
Dtags
Directory Tags for Lazy Programmers
Stars: ✭ 351 (+1304%)
Mutual labels:  parallel-processing
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-4%)
Mutual labels:  parallel-processing
ImagingKit
Java library for imaging tasks that integrates well with the java.awt.image environment
Stars: ✭ 16 (-36%)
Mutual labels:  parallel-processing
Massiv
Efficient Haskell Arrays featuring Parallel computation
Stars: ✭ 328 (+1212%)
Mutual labels:  parallel-processing
Mug
A small Java 8 util library, complementary to Guava (BiStream, Substring, MoreStreams, Parallelizer).
Stars: ✭ 236 (+844%)
Mutual labels:  parallel-processing
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+1968%)
Mutual labels:  parallel-processing
Future.apply
🚀 R package: future.apply - Apply Function to Elements in Parallel using Futures
Stars: ✭ 159 (+536%)
Mutual labels:  parallel-processing
az-ml-batch-score
Deploying a Batch Scoring Pipeline for Python Models
Stars: ✭ 17 (-32%)
Mutual labels:  parallel-processing
Future
🚀 R package: future: Unified Parallel and Distributed Processing in R for Everyone
Stars: ✭ 735 (+2840%)
Mutual labels:  parallel-processing
Pagmo2
A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
Stars: ✭ 540 (+2060%)
Mutual labels:  parallel-processing
Jobrunr
An extremely easy way to perform background processing in Java. Backed by persistent storage. Open and free for commercial use.
Stars: ✭ 331 (+1224%)
Mutual labels:  parallel-processing

Paratize

Build Status Hex.pm Version

Elixir library providing some handy parallel processing facilities that supports configuring number of workers and timeout.

This library is inspired by Parex.

Documentation

API documentation is available at http://hexdocs.pm/paratize

Adding Paratize To Your Project

To use Paratize with your projects, edit your mix.exs file and add it as a dependency:

defp deps do
  [
    {:paratize, "~> x.x.x"},
  ]
end

Examples

Paratize is designed to run slow tasks in parallel. There are two processor implementatons, first the chunk based implementation Paratize.Chunk and the second the worker pool based implementation Paratize.Pool. Both modules have the same API.

  • parallel_exec(fun_list, task_options)
  • parallel_map(arg_list, fun, task_options)
  • parallel_each(arg_list, fun, task_options)

To execute a list of functions in parallel,

import Paratize.Pool

function_list = [
  fn -> Math.fib(40) end,
  fn -> :timer.sleep(5000) end,
  fn -> HTTPotion.get("http://wwww.reddit.com") end
]

parallel_exec(function_list) # => [102334155, :ok, %HTTPotion.Response{body...}]

function_keyword_list = [
  fib: fn -> Math.fib(40) end,
  hang: fn -> :timer.sleep(5000) end,
  web_request: fn -> HTTPotion.get("http://wwww.reddit.com") end
]

parallel_exec(function_keyword_list) # => [fib: 102334155, hang: :ok, web_request: %HTTPotion.Response{body...}]

To execute a map in parallel,
(useful when results are needed for further processing)

import Paratize.Pool

slow_func = fn arg -> :timer.sleep(1000); arg + 1 end
workload = 1..100

{time, result} = :timer.tc fn -> workload |> parallel_map(slow_func) |> Enum.join(", ") end
time # => 13034452 (8 CPU cores system, running 8 workers)

To execute a each in parallel,
(useful when resultset is large, and can be processed individually to prevent memory hog)

import Paratize.Pool

lots_of_urls |> parallel_each(fn url ->
  HTTPotion.get(url) |> parse_page |> save_meta_data
end)

Task Options

Each function accepts task options to customize the parallel processing.

  • size - the number of parallel workers, defaults to the number of system cores given by :erlang.system_info(:schedulers)
  • timeout - in milliseconds, the minimum time given for a function to complete, defaults to 5000. If timeout happens, the entire parallel processing crashes with exit(:timeout,...). To disable timeout, use :infinity.

Considerations

To achieve maximum parallelism, %Paratize.TaskOptions{} size should be set to size of your workload,

alias Paratize.Pool

slow_func = fn arg -> :timer.sleep(1000); arg + 1 end
workload = 1..100

{time, result} = :timer.tc fn ->
    workload |> Pool.parallel_map(slow_func, size: Enum.count(workload)) |> Enum.join(", ")
end
time # => 1004370 (Running 100 workers)

The %Paratize.TaskOptions{} timeout should not be relied upon for precise timing out of each workload, because it is not strictly enforced. It is an implementation detail that reasonably crashes the processor if no further work is completed after the timeout period has lapsed.

LICENSE

This software is licensed under MIT LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].