{"id":20761956,"url":"https://github.com/composewell/concurrency-benchmarks","last_synced_at":"2025-08-23T18:07:30.713Z","repository":{"id":45831153,"uuid":"147689195","full_name":"composewell/concurrency-benchmarks","owner":"composewell","description":"Benchmarks comparing concurrency overhead of streamly and async","archived":false,"fork":false,"pushed_at":"2021-05-26T07:43:30.000Z","size":110,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-30T06:35:28.936Z","etag":null,"topics":["benchmarks","concurrency","concurrency-benchmarks","haskell"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/composewell.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-06T14:48:15.000Z","updated_at":"2023-09-29T06:03:16.000Z","dependencies_parsed_at":"2022-09-13T11:00:52.294Z","dependency_job_id":null,"html_url":"https://github.com/composewell/concurrency-benchmarks","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/composewell/concurrency-benchmarks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fconcurrency-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fconcurrency-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fconcurrency-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fconcurrency-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/composewell","download_url":"https://codeload.github.com/composewell/concurrency-benchmarks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fconcurrency-benchmarks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271760490,"owners_count":24816433,"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-08-23T02:00:09.327Z","response_time":69,"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":["benchmarks","concurrency","concurrency-benchmarks","haskell"],"created_at":"2024-11-17T10:28:14.018Z","updated_at":"2025-08-23T18:07:30.670Z","avatar_url":"https://github.com/composewell.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# concurrency-benchmarks\n\n[![Hackage](https://img.shields.io/hackage/v/concurrency-benchmarks.svg?style=flat)](https://hackage.haskell.org/package/concurrency-benchmarks)\n[![Build Status](https://travis-ci.org/composewell/concurrency-benchmarks.svg?branch=master)](https://travis-ci.org/composewell/concurrency-benchmarks)\n[![Windows Build status](https://ci.appveyor.com/api/projects/status/wqban615v9f21xqi?svg=true)](https://ci.appveyor.com/project/harendra-kumar/concurrency-benchmarks)\n\nBenchmarks to compare the concurrency overhead of\nconcurrent [streamly](https://github.com/composewell/streamly) streams and the\n[async](https://hackage.haskell.org/package/async) package. If you are familiar\nwith `async`, see [this quick\nguide](https://github.com/composewell/streamly/blob/master/docs/Async.md) for\nequivalent features of streamly. For more detailed introduction to streamly see\n[this tutorial](https://hackage.haskell.org/package/streamly/docs/Streamly-Tutorial.html).\n\n## How to run\n\nRun the `run.sh` script to run the benchmarks and create the charts. You can\nuse `cabal new-bench` or `stack bench` to run the benchmarks. To generate\ncharts, run the benchmarks with `--csv-raw=results.csv` option and then run\n`makecharts results.csv`. Charts are generated in the `charts` directory.\n\nIMPORTANT NOTE: THE `maxrss` FIGURES REPORTED BY GAUGE WILL NOT BE CORRECT\nUNLESS YOU RUN ONE BENCHMARK AT A TIME. This is because `maxrss` is tracked per\nprocess.\n\n## Methodology\n\nA total of 10,000 tasks are run for each concurrency mechanism being compared.\nTwo independent experiments are performed:\n\n1. In the first experiment, each task is just a noop i.e. it takes almost 0 time\n   to execute.\n2. In the second experiment, each task introduces a 5 second delay\n\nThe first case shows streamly's smart scheduling to automatically run the tasks\nin less number of threads than the actual number of tasks.  When the tasks do\nnot block and have a very low latency, streamly may run multiple tasks per\nthread.  Therefore streamly is much faster on this benchmark.\n\nIn the second case a 5 second delay is introduced to make sure that streamly\nuses one thread per task which is similar to what `async` does and therefore a\nfair comparison.  For the `async` package, `mapConcurrently` is used which can\nbe compared with streamly's `ahead` style stream.\n\nFor streamly this is the code that is benchmarked, by default streamly has a\nlimit on the buffer size and the number of threads, we set those limits to `-1`\nwhich means there is no limit:\n\n```haskell\n    let work = (\\i -\u003e threadDelay 5000000 \u003e\u003e return i)\n    in Stream.drain\n        $ Stream.fromAhead\n        $ Stream.maxBuffer (-1)\n        $ Stream.maxThreads (-1)\n        $ Stream.fromFoldableM $ map work [1..10000]\n```\n\nFor `async` this is the code that is benchmarked:\n\n```haskell\n    let work = (\\i -\u003e threadDelay 5000000 \u003e\u003e return i)\n    mapConcurrently work [1..10000]\n```\n\n## Results\n\nThese charts compare\n[streamly-0.7.2](https://github.com/composewell/streamly/tree/03cf686ca7e3fe1093b064c9763de8b684cce0f4)\nand `async-2.2.2`.\n\nWhen compiling, `-threaded -with-rtsopts \"-N\"` GHC options were used to enable\nthe use of multiple processor cores in parallel.\n\nFor streamly, results for both `async` and `ahead` style streams are shown.\n\n### Zero delay case\n\n#### Peak Memory Consumed\n\n\u003cimg src=\"https://github.com/composewell/concurrency-benchmarks/blob/master/charts/10,000tasks,0secdelay-maxrss.svg\" alt=\"Comparison of maxrss\" width=\"640\"/\u003e\n\n#### Time Taken\n\n\u003cimg src=\"https://github.com/composewell/concurrency-benchmarks/blob/master/charts/10,000tasks,0secdelay-time.svg\" alt=\"Comparison of time\" width=\"640\"/\u003e\n\n### 5 second delay case\n\n#### Peak Memory Consumed\n\n\u003cimg src=\"https://github.com/composewell/concurrency-benchmarks/blob/master/charts/10,000tasks,5secdelay-maxrss.svg\" alt=\"Comparison of maxrss\" width=\"640\"/\u003e\n\n#### Time Taken\n\nNote, this time shows the overhead only and not the full time taken by the\nbenchmark. For example the actual time taken by the `async` benchmark is\n`5.135` seconds, but since 5 second in this is the delay introduced by each\nparallel task, we compute the overhead of concurrency by deducting the 5\nseconds from the actual time taken, so the overhead is `135 ms` in case of\n`async`.\n\n\u003cimg src=\"https://github.com/composewell/concurrency-benchmarks/blob/master/charts/10,000tasks,5secdelay-time.svg\" alt=\"Comparison of time\" width=\"640\"/\u003e\n\n## Feedback\n\nFeedback is welcome. Please raise an issue, send a PR or send an email to the\nauthor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomposewell%2Fconcurrency-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomposewell%2Fconcurrency-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomposewell%2Fconcurrency-benchmarks/lists"}