{"id":16833552,"url":"https://github.com/ole/concurrencybenchmark","last_synced_at":"2025-08-23T04:06:24.192Z","repository":{"id":41442451,"uuid":"509585193","full_name":"ole/ConcurrencyBenchmark","owner":"ole","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-02T12:21:55.000Z","size":1199,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T04:35:06.950Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ole.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-01T20:48:24.000Z","updated_at":"2022-07-06T07:49:32.000Z","dependencies_parsed_at":"2022-09-21T09:01:24.123Z","dependency_job_id":null,"html_url":"https://github.com/ole/ConcurrencyBenchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ole/ConcurrencyBenchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ole%2FConcurrencyBenchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ole%2FConcurrencyBenchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ole%2FConcurrencyBenchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ole%2FConcurrencyBenchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ole","download_url":"https://codeload.github.com/ole/ConcurrencyBenchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ole%2FConcurrencyBenchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271740720,"owners_count":24812642,"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":[],"created_at":"2024-10-13T11:54:35.560Z","updated_at":"2025-08-23T04:06:24.173Z","avatar_url":"https://github.com/ole.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConcurrencyBenchmark\n\nBenchmarks for CPU-bound computation comparing different parallelization strategies.\n\n## Usage\n\nRun the benchmarks:\n\n```sh\nswift run -c release benchmark run \\\n  --cycles 3 \\\n  --max-size 256k \\\n  BenchmarkData/benchmark-data.json\n```\n\nCreate a chart:\n\n```sh\nswift run -c release benchmark render \\\n  BenchmarkData/benchmark-data.json \\\n  BenchmarkData/chart.png \\\n  --amortized false\n```\n\nFor more options:\n- See the [Swift Collections Benchmark Getting Started Guide](https://github.com/apple/swift-collections-benchmark/blob/main/Documentation/01%20Getting%20Started.md)\n- `swift run -c release benchmark run --help`\n- `swift run -c release benchmark render --help`\n\n## Analysis\n\nThis chart was created on an Apple M1 Pro (10 cores):\n\n![Current chart](BenchmarkData/chart.png)\n\nNote: the x axis should be called \"number of subtasks\", not \"input size\":\n\n- The benchmark always performs 10 million computations (this is [the `totalWorkload` variable](https://github.com/ole/ConcurrencyBenchmark/blob/main/Sources/BenchmarkCLI/Main.swift#L5) in the code)\n- If \"input size\" = 10, the workload is split into 10 \"subtasks\". E.g. we're calling `concurrentPerform` with 10 iterations, where each iteration perform 10 million / 10 = 1 million computations. Same for the `TaskGroup` (10 child tasks) and `DispatchQueue.global.async()` (10 work items passed to the global queue) benchmarks.\n- For large input sizes, this creates a very large number of subtasks with each subtask doing very little work. This is why the curves go up as the number of subtasks increases.\n- The \"No parallelism (1 core)\" task always performs the same number of computations, regardless of input size. This is why the line is flat.\n- We're passing `--amortized false` when rendering the chart to show the total elapsed time. Without this, the chart would depict the time per \"subtask\", which is meaningless to us because the amount of work per subtask isn't constant. \n\nObservations:\n\n- The pure computational work takes ~3 ms on this machine (see the flat line). \n- At 1 subtask (no parallelism), all strategies have effectively the same performance (as expected).\n- At the optimal level of parallelism (around 32–64 subtasks), all parallelization strategies are are almost 10× as fast as the single-core benchmark (as expected).\n- `DispatchQueue.concurrentPerform` is more efficient than `TaskGroup` and `DispatchQueue.global().async` as the number of subtasks increases.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fole%2Fconcurrencybenchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fole%2Fconcurrencybenchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fole%2Fconcurrencybenchmark/lists"}