Snappy is a compression library focused on high speed and moderate compression ratios. It targets scenarios where CPU time matters more than minimum file size.
Overview
Snappy compresses and decompresses byte streams with emphasis on throughput rather than maximum compression. Compared with zlib’s fastest mode it is much faster on typical inputs while producing larger outputs, and keeps a stable bitstream format across versions.
The decompressor is designed to handle corrupted or malicious input without crashing. Snappy is implemented primarily in C++ with a stable format used in production settings. A C header provides bindings for callers that prefer C interfaces, and third-party language bindings are available.
Published benchmarks cite compression and decompression speeds on 64-bit x86 hardware, with typical ratios varying by content type. Already-compressed formats such as JPEG and PNG see little benefit, while text and HTML compress more noticeably. Optimization work targets 64-bit x86 but the code runs on other architectures with possible performance trade-offs.
Consumers link against the compiled library and call interfaces from snappy.h using standard strings or more flexible input sources documented in headers. Optional tools ship for microbenchmarks, unit tests, and comparison against other compressors when those libraries are present at build time.
Key features
- High-speed compression and decompression
- Stable documented bitstream format
- Robust decompressor on bad input
- C++ primary API
- C language bindings header
- Flexible non-string input interfaces
- Benchmark and unit test utilities
- CMake-based builds
Use cases
- Low-latency payload compression in applications
- Internal RPC or storage compression
- When CPU time outweighs minimum size
- Embedding compression via C or C++
- Comparing speed against zlib and LZ family