Popularity
6.1
Growing
Activity
0.0
Stable
15
5
0

Monthly Downloads: 24
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Data     Unboxed    
Latest version: v0.4.0.0

unboxed-ref alternatives and similar packages

Based on the "unboxed" category.
Alternatively, view unboxed-ref alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of unboxed-ref or a related project?

Add another 'unboxed' Package

README

unboxed-ref

Hackage Test Status

This package provide fast unboxed references for ST and IO monad and atomic operations for IORefU Int type. Unboxed reference is implemented using single cell MutableByteArray s to eliminate indirection overhead which MutVar# s a carry, on the otherhand unboxed reference only support limited type(instances of Prim class).

A simple diagram could show the difference between IORef Int with IORefU Int:

data Foo = Foo {-# UNPACK #-} (IORef Int)

        +-----------+    +-------------+    +---------+
        | Foo |  *  +--->+ MutVar# | * +--->+ I# | i# |
        +-----------+    +-------------+    +---------+

data Bar = Bar {-# UNPACK #-} (IORefU Int)

        +-----------+    +------------------------+
        | Bar |  *  +--->+ MutableByteArray# | i# |
        +-----------+    +------------------------+

Benchmark

Modified from this benchmark.

$ cd bench && cabal build
$ time ./dist/build/bench-ref/bench-ref
143
./dist/build/bench-ref/bench-ref  19.76s user 0.02s system 99% cpu 19.785 total
------------------------------------------------------------
$ time ./dist/build/bench-unboxed-ref/bench-unboxed-ref
143
./dist/build/bench-unboxed-ref/bench-unboxed-ref  16.66s user 0.02s system 99% cpu 16.694 total
------------------------------------------------------------
$ ./dist/build/bench-unboxed-ref-atomic/bench-unboxed-ref-atomic
50500000
------------------------------------------------------------
$ ./dist/build/bench-ref-atomic/bench-ref-atomic
3597361