stm-ringbuffer: Ring buffer implementation in STM

[ bsd3, concurrency, library ] [ Propose Tags ] [ Report a vulnerability ]

This package provides a ring buffer in STM and a wrapper which mimics the interface to TBQueue.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies array (>=0.5.8 && <0.6), base (>=4.18.3 && <4.23), dlist (>=1.0 && <1.1), stm (>=2.5.3 && <2.6) [details]
Tested with ghc ==9.6.7, ghc ==9.8.4, ghc ==9.10.3, ghc ==9.12.2, ghc ==9.14.1
License BSD-3-Clause
Copyright (c) Greg Baimetov 2026
Author Greg Baimetov
Maintainer Greg Baimetov
Uploaded by gregbaimetov at 2026-04-20T01:36:19Z
Category Concurrency
Source repo head: git clone github.com/Greg-Bm/stm-ringbuffer.git
Distributions
Downloads 5 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-04-20 [all 1 reports]

Readme for stm-ringbuffer-0.1.0.0

[back to package description]

STM ringbuffer

About

This is an implementation of a ring buffer for STM. A wrapper exposing a TBQueue-like interface is provided, offering improved performance compared to the current implementation of TBQueue in the STM package.

This work is similar to https://github.com/haskell/stm/pull/70 . However, this implementation is hopefully correct and supports ringbuffers with size == 0.

Usage

Mixins can be used to quickly replace the standard TBQueue implementation with the one in this library. Add the following fields to your cabal file:

library foo
  build-depends:
    stm
    stm-queue
  mixins:
    stm-queue (Control.Concurrent.STM.TRingBuffer.TBQueue as Control.Concurrent.STM.TBQueue),
    stm hiding (Control.Concurrent.STM.TBQueue)

Development

It is recommended to add the following to your cabal.project.local file:

tests: True
benchmarks: True
semaphore: True

Benchmark results

In benchmarks, TRingBuffer.TBQueue demonstrates improved performance compared to STM's TBQueue:

All
  concurrent spsc
    TBQueue:    OK
      119  ms ± 6.8 ms
    RB.TBQueue: OK
      109  ms ± 7.3 ms
  concurrent mpmc
    TBQueue:    OK
      193  ms ±  14 ms
    RB.TBQueue: OK
      136  ms ± 7.0 ms
  burst
    TBQueue:    OK
      114  ms ± 7.2 ms
    RB.TBQueue: OK
      108  ms ± 6.8 ms