superbuffer

Efficiently build a bytestring from smaller chunks

https://github.com/agrafix/superbuffer#readme

Version on this page:0.3.1.1
LTS Haskell 22.39:0.3.1.2
Stackage Nightly 2023-12-26:0.3.1.2
Latest on Hackage:0.3.1.2

See all snapshots superbuffer appears in

BSD-3-Clause licensed by Alexander Thiemann
Maintained by [email protected]
This version can be pinned in stack with:superbuffer-0.3.1.1@sha256:37df3bd4837a8fd6524e89836c444d2fdaedb0ede99b9e6c6b7988f5be4a0644,1727

Module documentation for 0.3.1.1

Depends on 2 packages(full list with versions):

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.

Usage

{-# 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!"

Benchmarks

See: Benchmarks for 0.3.0.0