{"id":13507320,"url":"https://github.com/seantanly/elixir-paratize","last_synced_at":"2025-10-21T15:56:41.164Z","repository":{"id":34102745,"uuid":"37929944","full_name":"seantanly/elixir-paratize","owner":"seantanly","description":"Elixir library providing some handy parallel processing facilities that supports configuring number of workers and timeout.","archived":false,"fork":false,"pushed_at":"2018-02-25T07:24:50.000Z","size":635,"stargazers_count":29,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-21T15:56:29.880Z","etag":null,"topics":["elixir-library","parallel-processing"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seantanly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-23T16:11:35.000Z","updated_at":"2025-09-26T22:04:22.000Z","dependencies_parsed_at":"2022-07-29T20:09:50.601Z","dependency_job_id":null,"html_url":"https://github.com/seantanly/elixir-paratize","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/seantanly/elixir-paratize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seantanly%2Felixir-paratize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seantanly%2Felixir-paratize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seantanly%2Felixir-paratize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seantanly%2Felixir-paratize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seantanly","download_url":"https://codeload.github.com/seantanly/elixir-paratize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seantanly%2Felixir-paratize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280290185,"owners_count":26305279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir-library","parallel-processing"],"created_at":"2024-08-01T02:00:31.059Z","updated_at":"2025-10-21T15:56:41.134Z","avatar_url":"https://github.com/seantanly.png","language":"Elixir","readme":"Paratize\n========\n[![Build Status](https://travis-ci.org/seantanly/elixir-paratize.svg?branch=master)](https://travis-ci.org/seantanly/elixir-paratize)\n[![Hex.pm Version](http://img.shields.io/hexpm/v/paratize.svg?style=flat)](https://hex.pm/packages/paratize)\n\nElixir library providing some handy parallel processing facilities that supports configuring number of workers and timeout.\n\nThis library is inspired by [Parex](https://github.com/StevenJL/parex).\n\n## Documentation\n\nAPI documentation is available at [http://hexdocs.pm/paratize](http://hexdocs.pm/paratize)\n\n## Adding Paratize To Your Project\n\nTo use Paratize with your projects, edit your `mix.exs` file and add it as a dependency:\n\n```elixir\ndefp deps do\n  [\n    {:paratize, \"~\u003e x.x.x\"},\n  ]\nend\n```\n\n## Examples\n\nParatize 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.\n\n* `parallel_exec(fun_list, task_options)`\n* `parallel_map(arg_list, fun, task_options)`\n* `parallel_each(arg_list, fun, task_options)`\n\nTo execute a list of functions in parallel,\n\n```elixir\nimport Paratize.Pool\n\nfunction_list = [\n  fn -\u003e Math.fib(40) end,\n  fn -\u003e :timer.sleep(5000) end,\n  fn -\u003e HTTPotion.get(\"http://wwww.reddit.com\") end\n]\n\nparallel_exec(function_list) # =\u003e [102334155, :ok, %HTTPotion.Response{body...}]\n\nfunction_keyword_list = [\n  fib: fn -\u003e Math.fib(40) end,\n  hang: fn -\u003e :timer.sleep(5000) end,\n  web_request: fn -\u003e HTTPotion.get(\"http://wwww.reddit.com\") end\n]\n\nparallel_exec(function_keyword_list) # =\u003e [fib: 102334155, hang: :ok, web_request: %HTTPotion.Response{body...}]\n\n```\n\nTo execute a `map` in parallel,  \n(useful when results are needed for further processing)\n\n```elixir\nimport Paratize.Pool\n\nslow_func = fn arg -\u003e :timer.sleep(1000); arg + 1 end\nworkload = 1..100\n\n{time, result} = :timer.tc fn -\u003e workload |\u003e parallel_map(slow_func) |\u003e Enum.join(\", \") end\ntime # =\u003e 13034452 (8 CPU cores system, running 8 workers)\n```\n\nTo execute a `each` in parallel,  \n(useful when resultset is large, and can be processed individually to prevent memory hog)\n\n```elixir\nimport Paratize.Pool\n\nlots_of_urls |\u003e parallel_each(fn url -\u003e\n  HTTPotion.get(url) |\u003e parse_page |\u003e save_meta_data\nend)\n\n```\n\n## Task Options\n\nEach function accepts task options to customize the parallel processing.\n\n* size - the number of parallel workers, defaults to the number of system cores given by `:erlang.system_info(:schedulers)`\n* 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`.\n\n\n## Considerations\n\nTo achieve maximum parallelism, `%Paratize.TaskOptions{}` size should be set to size of your workload,\n\n```elixir\nalias Paratize.Pool\n\nslow_func = fn arg -\u003e :timer.sleep(1000); arg + 1 end\nworkload = 1..100\n\n{time, result} = :timer.tc fn -\u003e\n    workload |\u003e Pool.parallel_map(slow_func, size: Enum.count(workload)) |\u003e Enum.join(\", \")\nend\ntime # =\u003e 1004370 (Running 100 workers)\n\n```\n\nThe `%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.\n\n\n## LICENSE\n\nThis software is licensed under [MIT LICENSE](LICENSE.md).\n","funding_links":[],"categories":["Algorithms and Data structures"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseantanly%2Felixir-paratize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseantanly%2Felixir-paratize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseantanly%2Felixir-paratize/lists"}