unboxed-ref: Fast unboxed references for ST and IO monad

[ bsd3, data, library ] [ Propose Tags ]
This version is deprecated.

Fast unboxed references for ST and IO monad


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.4.0.0 (info)
Change log ChangeLog.md
Dependencies base (>=4.8 && <5.0), ghc-prim (>=0.4), primitive [details]
License BSD-3-Clause
Copyright Copyright (c) Winter 2017
Author winter
Maintainer drkoster@qq.com
Revised Revision 1 made by winterland at 2017-05-08T11:13:30Z
Category Data
Home page https://github.com/winterland1989/unboxed-ref
Bug tracker https://github.com/winterland1989/unboxed-ref/issues
Uploaded by winterland at 2017-05-08T11:10:43Z
Distributions LTSHaskell:0.4.0.0, NixOS:0.4.0.0, Stackage:0.4.0.0
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 3692 total (26 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-08 [all 1 reports]

Readme for unboxed-ref-0.1.0.0

[back to package description]

unboxed-ref

Hackage

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