Giter Club home page Giter Club logo

hs-zstd's Introduction

Zstandard bindings for Haskell

Travis

This library provides Haskell bindings to the Zstandard compression library.

Note that is now the official repositoryc for the zstd Haskell package. The original authors (Facebook) are no longer interested in maintaining it.

The library is structured to provide several layers of abstraction.

  • For the simplest use cases, the top-level Zstd module is the best place to get started.

  • If you need to stream a large amount of data with a constant memory footprint, use the Zstd.Streaming module. See also the conduit-zstd package which provides a very thin wrapper to integrate with the conduit library. If you need to use lazy bytestrings instead, see the Zstd.Lazy module. This is built using the abstractions from the Zstd.Streaming module.

  • When your usage is dominated by lots of small messages (presumably using pre-computed compression dictionaries), use the Zstd.Efficient module to amortize the cost of allocating and initializing context and dictionary values.

Join in

If you'd like to help improve the code, please read the contribution guidelines. This discusses how to file bugs and submit changes to the code itself.

API documentation

The APIs should be easy to understand and work with, and you can find documentation on Hackage.

hs-zstd's People

Contributors

luispedro avatar roberth avatar bos avatar vmchale avatar dpwiz avatar

Stargazers

Adrian Sieber avatar  avatar Andrew Cowie avatar  avatar eduardo morango avatar

Watchers

 avatar  avatar James Cloos avatar  avatar

hs-zstd's Issues

multi-core compression

Looking at zstd code enabling ZSTD_MULTITHREAD would enable that, but it probably needs testing if it works with the bindings.

Also needs to set ZSTD_c_nbWorkers.

Context memory inflates memory usage beyond RTS heap limit

hs-zstd allocates significant memory that isn't in the Haskell heap. This has implications:

  • The heap size limit becomes less effective (RTS -M flag).
  • The RTS is unaware of memory pressure when multiple contexts are created, especially when multiple contexts are created while there is little Haskell activity to trigger garbage collection.

I've lost a lot of time troubleshooting these issues, so I hope these can be prevented in the future.
Some ideas:

  • Codec.Zstd.Streaming: explicitly deallocate the stream context when Done. This will reduce severity of the memory amplification from O(number of streams between GCs) to O(number of concurrent streams). I'll give this a shot.
  • The C library seems to support the use of a custom allocator. If hs-zstd were to use Haskell-provided memory regions in pinned memory, the RTS will be able to collect when appropriate and enforce the heap size limit.
  • Improve documentation to acknowledge these intricacies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.