MCPcopy Index your code
hub / github.com/cyclosresearch/ring-buffers-research

github.com/cyclosresearch/ring-buffers-research @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
215 symbols 350 edges 35 files 1 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Cross-Thread Ring Buffers Research Environment

Hey there! In the pursuit of research I decided to create a simple environment for testing new ring buffer implementations. Most of them are safe (some are designed to be unsafe) however this is primarily for educational purposes and a place to test new ideas before using them in production

This repository is intended to be used by other low latency enthusiasts so I've tried to make the code as modular as possible so that it's easy to add new ring buffer implementations. I've also included some notes throughout the code to help ease the process of adding new implementations

Along with the code, there's also a script which visualizes the results of the experiments. The two primary dependent variables I was interested in were throughput in bytes/ms and throughput in msgs/us. There are a few more metrics included in the results dump so feel free to play around with them

Usage

  • Most of the configuration options are in the main.rs file, so feel free to change the parameters to your liking before running the program
    • Setting FULL_SUITE_TESTING to true will run all the experiments under varying payload & ring size combinations (tons of data but costly to compile)

bash rustup install nightly rustup default nightly cargo run --release

To analyze the results, open the analyze_results.py file and change the parameters to what you're interested in and run the script via bash python3 analyze_results.py

## Adding new ring implementations

  1. Decide which channel type you're interested in (SPSC is the simplest to start with)
  2. Clone one of the implementations (if you'd like to start from a baseline)
  3. Create new file under that channel type's folder
  4. Change the name of the ring to something unique
  5. Implement your targeted changes / tuning
  6. Add the ring details to rings/{channel_type}/mod.rs, rings/mod.rs, experiment.rs, full_suite_test.rs, and main.rs (notes are laid out for guidance)

There are some low-hanging fruit optimizations that can be made to some of the implementations, I'll leave them as an exercise to the reader ;)

Example Results

MPMC

MPMC Bytes Throughput Heatmap MPMC Msg Throughput Heatmap MPMC Controlled Comparison MPMC Comparison by Config


MPSC

MPSC Bytes Throughput Heatmap MPSC Msg Throughput Heatmap MPSC Controlled Comparison MPSC Comparison by Config


SPMC

SPMC Bytes Throughput Heatmap SPMC Msg Throughput Heatmap SPMC Controlled Comparison SPMC Comparison by Config


SPSC

SPSC Bytes Throughput Heatmap SPSC Msg Throughput Heatmap SPSC Controlled Comparison SPSC Comparison by Config


I hope y'all enjoy and have some fun with this - Built by Dub | CyclosResearch

Extension points exported contracts — how you extend this code

Sender (Interface)
(no doc) [21 implementers]
src/rings/mod.rs
AnyPayload (Interface)
(no doc) [2 implementers]
src/payload.rs
Receiver (Interface)
(no doc) [21 implementers]
src/rings/mod.rs

Core symbols most depended-on inside this repo

get
called by 47
src/utils.rs
run
called by 21
src/experiment.rs
plot_heatmap_by_implementation
called by 8
analyze_results.py
plot_implementation_comparison
called by 8
analyze_results.py
print_relative_results
called by 8
src/measurements/group.rs
plot_stacked_metrics_by_implementation
called by 7
analyze_results.py
plot_bar_comparison
called by 7
analyze_results.py
push
called by 6
src/rings/mpsc/global_tail.rs

Shape

Method 111
Class 82
Function 13
Enum 6
Interface 3

Languages

Rust96%
Python4%

Modules by API surface

src/payload.rs13 symbols
src/rings/spsc/safe_skipping_no_box_ptr.rs9 symbols
src/rings/spmc/broadcaster_padded.rs9 symbols
src/rings/mpsc/indiv_spsc_group.rs9 symbols
src/rings/mpmc/broadcaster.rs9 symbols
src/measurements/individual.rs9 symbols
src/rings/spsc/slot_lock_local_tail_copy.rs8 symbols
src/rings/spsc/safe_skipping.rs8 symbols
src/rings/spmc/broadcaster.rs8 symbols
src/rings/mpsc/local_tail_lossy_padded.rs8 symbols
src/rings/mpsc/local_tail_lossy.rs8 symbols
src/rings/mpsc/global_tail_lossy.rs8 symbols

For agents

$ claude mcp add ring-buffers-research \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact