• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created over 10 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A haskell library implementing fast and scalable concurrent queues for x86, with a Chan-like API

Build Status

The library is available on hackage and you can install it with:

$ cabal install unagi-chan

Design

The idea is to design a queue around the x86 fetch-and-add instruction, which performs well under contention.

The queue is conceptually simple, consisting of: an infinite array, and two atomic counters, one for readers and another for writers. A read or write operation consists of incrementing the appropriate counter and racing to perform an atomic operation on the specified index.

If the writer wins it has written its value for the reader to find and exits. When it loses it does a rendezvous with the blocked or blocking reader, via another mechanism and hands off its value.

Linearizabillity

The queue has FIFO semantics, reasoning in terms of linearizability. Our atomic counter ensures that all non-overlapping reads and writes are assigned indices in temporal order.

Lockfree - ness

Operations are non-blocking, with the exception that a stalled writer may block at most one reader (the reader "assigned" to it by our internal counter).

Performance

Here is an example benchmark measuring the time taken to concurrently write and read 100,000 messages, with work divided amongst increasing number of readers and writers, comparing against the top-performing queues in the standard libraries. The inset graph shows a zoomed-in view on the implementations here.

Benchmarks

Some of these variants may be deprecated in the future if they are found to provide little performance benefit, or no unique features; you should benchmark and experiment with them for your use cases, and please submit pull requests for additions to the benchmark suite that reflect what you find.

More Repositories

1

directory-tree

A simple directory-like tree datatype, with useful IO functions, for Haskell
Haskell
25
star
2

hashabler

A haskell library for principled, cross-platform & extensible hashing of types, including an implementation of the FNV-1a algorithm. (DEVELOPMENT STALLED; Hashable NEEDS TO BE PREFIX CODE)
Haskell
23
star
3

unagi-bloomfilter

A fast, cache-efficient, concurrent bloom filter in Haskell
Haskell
19
star
4

chan-benchmarks

Criterion benchmarks for the different haskell concurrent channel implementations in base and stm
Haskell
17
star
5

ghc-timing-treemap

Visualize fine-grained timing data from ghc verbose logs
HTML
13
star
6

simple-actors

A Haskell library providing an idiomatic implementation of the actor model of concurrency
Haskell
13
star
7

haskomplete.vim

A vim ftplugin for magical contextual haskell code completions
Vim Script
10
star
8

almost-inline-asm-haskell-example

An example of using `foreign import prim` in ghc haskell to call assembly with low overhead
Haskell
8
star
9

chan-split

Haskell library providing concurrent Chans as read/write pairs. Also provides generic Chan, Cofunctor classes.
Haskell
7
star
10

fly-mis

In-browser simulation of "A Biological Solution to a Fundamental Distributed Computing Problem" by Afek et al.
JavaScript
6
star
11

zippo

A simple lens-based, generic, heterogenous, type-checked haskell zipper library
Haskell
6
star
12

yall

Lenses with a southern twang
Haskell
4
star
13

shapely-data

haskell library for conversion of arbitrary data types to a "structural form" built from the primitive sum, product types
Haskell
3
star
14

dilly.js

a silly library for loops with delays in JavaScript.
JavaScript
3
star
15

pez

A Potentially-Excellent Zipper library for haskell
Haskell
3
star
16

cofunctor

A small haskell module implementing contravariant functors
Haskell
2
star
17

proxy-kindness

A Haskell library for kind-polymorphic manipulation and inspection of Proxy values
Haskell
2
star
18

Befunge93

An old Befunge-93 interpreter I wrote in haskell
Haskell
2
star
19

combinator-calculus

A nice little typeclass for playing with combinator calculi in haskell
Haskell
2
star