{"id":51293449,"url":"https://github.com/grudshtein/mpmc-ring","last_synced_at":"2026-06-30T12:31:53.784Z","repository":{"id":319019023,"uuid":"1061317519","full_name":"grudshtein/mpmc-ring","owner":"grudshtein","description":"Header-only, bounded lock-free MPMC ring buffer for C++20 using per-slot sequence numbers, with a reproducible benchmark suite and latency histograms (p50/p95/p99/p99.9).","archived":false,"fork":false,"pushed_at":"2025-10-16T03:17:27.000Z","size":1981,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-17T06:03:43.394Z","etag":null,"topics":["benchmarking","concurrency","cpp","cpp20","lock-free","low-latency","mpmc","ring-buffer"],"latest_commit_sha":null,"homepage":"","language":"C++","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/grudshtein.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-21T17:14:14.000Z","updated_at":"2025-10-16T03:17:30.000Z","dependencies_parsed_at":"2025-10-17T19:39:53.202Z","dependency_job_id":null,"html_url":"https://github.com/grudshtein/mpmc-ring","commit_stats":null,"previous_names":["grudshtein/mpmc-ring"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/grudshtein/mpmc-ring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grudshtein%2Fmpmc-ring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grudshtein%2Fmpmc-ring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grudshtein%2Fmpmc-ring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grudshtein%2Fmpmc-ring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grudshtein","download_url":"https://codeload.github.com/grudshtein/mpmc-ring/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grudshtein%2Fmpmc-ring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34967614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"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":["benchmarking","concurrency","cpp","cpp20","lock-free","low-latency","mpmc","ring-buffer"],"created_at":"2026-06-30T12:31:52.735Z","updated_at":"2026-06-30T12:31:53.749Z","avatar_url":"https://github.com/grudshtein.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPMC Ring\n\n[![CI](https://github.com/grudshtein/mpmc-ring/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/grudshtein/mpmc-ring/actions/workflows/ci.yml)\n![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)\n\n![C++20](https://img.shields.io/badge/C%2B%2B-20-00599C?logo=c%2B%2B)\n![CMake \u003e=3.21](https://img.shields.io/badge/CMake-%3E%3D3.21-064F8C?logo=cmake)\n![Compilers](https://img.shields.io/badge/Compilers-MSVC%20%7C%20Clang%20%7C%20GCC-6aa84f)\n![Sanitizers](https://img.shields.io/badge/Sanitizers-ASan%20%7C%20TSan%20%7C%20UBSan-orange)\n\nMPMC Ring is a high-performance, bounded multi-producer/multi-consumer ring buffer for C++20.\nIt provides a work-conserving blocking (ticketed) path and a non-blocking `try_*` API,\nuses atomic operations (no mutexes), and targets low-latency inter-thread messaging.\nThe library is header-only and ships with benchmarks and tests for reproducibility.\n\n## Overview\nBounded multi-producer / multi-consumer ring buffer with:\n- Blocking, ticketed fast path and non-blocking `try_*` API\n- No mutexes; uses atomic operations. \n- Per-slot acquire/release handoff; relaxed cursors\n- Thread pinning and cursor padding; reproducible bench with CSV output\n\n## API\n- `try_push(const T\u0026) / try_push(T\u0026\u0026)`: non-blocking; returns `false` if full\n- `push(const T\u0026) / push(T\u0026\u0026)`: blocking (spins) until enqueued\n- `try_pop(T\u0026)`: non-blocking; returns `false` if empty\n- `pop(T\u0026)`: blocking (spins) until dequeued\n- Template: `MpmcRing\u003cT, /*Padding=*/bool\u003e` (cursor padding toggle). Owns bounded storage.\n  \nFull signatures: see [`include/mpmc.hpp`](../include/mpmc.hpp).\n\n## Build\n\n### Visual Studio (Windows)\n1. Open the folder as a **CMake Project**.\n2. Set **x64 | Release**.\n3. Run `tests` or `bench`.\n\nTypical paths:\n- `out/build/msvc-ninja-release/tests.exe`\n- `out/build/msvc-ninja-release/bench.exe`\n\n### MSYS2 / MinGW\n```bash\ncmake --preset=mingw-release\ncmake --build --preset=mingw-release -j\n./out/build/mingw-release/bench\n```\n\n## Benchmark defaults\n**Benchmark defaults:** producers=consumers=1, capacity=65,536, mode=blocking, warmup=2,500 ms, duration=17,500 ms, \nbucket_width=5 ns, buckets=4,096, padding=on, pinning=on, large_payload=off, move_only_payload=off.\n\n**Testbed:** Windows 11 (24H2)\n**CPU:** Intel Core i7-11800H (8c/16t)\n**Compiler:** MSVC 19.44 (Visual Studio 2022 17.10), `/O2 /GL`  \n**Build system:** CMake 4.1.1 + Ninja 1.11.1 (Release) \n**Power plan:** Legion Balance Mode (OEM Balanced)\n\n### Reproduce a 4p4c run\n```bash\n# Blocking (defaults)\n./out/build/mingw-release/bench --producers 4 --consumers 4\n\n# Non-blocking A/B\n./out/build/mingw-release/bench --producers 4 --consumers 4 --blocking off\n```\nSee `--help` for all options and defaults.\n\n## Results (summary):\n**Figure settings (used for all charts unless stated):** \nproducers=consumers=4, capacity=65,536, mode=blocking, warmup=2,500 ms, duration=17,500 ms, \nbucket_width=5 ns, buckets=4,096, padding=on, pinning=on, large_payload=off, move_only_payload=off.\n\n![Blocking vs Non-blocking Throughput (MPMC)](fig/mode_comparison.png)\n![Latency vs Pinning/Padding (4p4c)](fig/latency_vs_pinning_padding.png)\n![Latency vs Payload (4p4c)](fig/latency_vs_payload.png)\n![Latency vs Threads](fig/latency_vs_threads.png)\n![Latency Distribution (4p4c)](fig/pop_hist.png)\n\n### Blocking vs non-blocking:\nAt 4p4c, blocking outperforms non-blocking by ~2–3× on this host, while tightening p99/p999.\n### Pinning and padding:\nMaterially reduce tail latency.\n### Payload sensitivity:\nLarge copyable payloads pay for data movement; move-only payloads keep latency close to small POD.\n### Concurrency:\nAs threads increase, p50, p99, and p999 grow.\n\n### Throughput notes:\n- On this Windows testbed, total throughput plateaued by 4p4c despite the ticketed fast path. \n- Explicit thread pinning (affinity APIs) did not change the result. \n- Blocking is ~2–3× faster than non-blocking at 4p4c, and pinning/padding primarily tighten tails. \n- On a single-socket Linux host, higher scaling is expected.\n- Next steps for increased performance: sharding the queue (N sub-rings).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrudshtein%2Fmpmc-ring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrudshtein%2Fmpmc-ring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrudshtein%2Fmpmc-ring/lists"}