superbuffer: Efficiently build a bytestring from smaller chunks

[ bsd3, library, web ] [ Propose Tags ]

Efficiently (both fast and memory efficient) build a bytestring from smaller chunks

[Skip to Readme]
Versions [faq],,,,
Dependencies base (>=4.8 && <5), bytestring (<0.11) [details]
License BSD-3-Clause
Copyright 2016 - 2017 Alexander Thiemann <>
Author Alexander Thiemann
Revised Revision 1 made by AlexanderThiemann at Fri May 26 17:11:33 UTC 2017
Category Web
Home page
Uploaded by AlexanderThiemann at Mon Mar 27 21:30:19 UTC 2017
Distributions LTSHaskell:, NixOS:, Stackage:
Downloads 3713 total (208 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-03-27 [all 1 reports]




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

For package maintainers and hackage trustees

Readme for superbuffer-

[back to package description]

Haskell SuperBuffer

CircleCI Hackage

The superbuffer packages was designed to efficiently build up bytestrings from IO actions producing smaller chunks. The goal was to reduce memory overhead as much as possible while still being as fast as possible. In our use case, it reduced total memory usage of the program from 350 MB (bytestring builder) to 50 MB (superbuffer). For speed see benchmarks below. Note that the speed heavily depends on a good choice of the initial buffer size. superbuffer outperforms or performs similar to the bytestring alternatives consistently. superbuffer outperforms buffer-builder.


{-# LANGUAGE OverloadedStrings #-}
module Example where

import Data.ByteString.SuperBuffer
import qualified Data.ByteString as BS

myBS :: IO BS.ByteString
myBS =
    -- note: performance of superbuffer heavily depends on a
    -- smart choice of the initial buffer size. Benchmark to
    -- find what suits your needs.
    withBuffer 1024 $ \buf ->
    do appendBuffer buf "Hello "
       appendBuffer buf "World!"


See: Benchmarks for