Skip to content
EntityQ3487131· pop 8· linked from 264 articles

Also known as Zippy, libsnappy

fast data compression and decompression library written in C++ by Google

Source code

Snappy is a compression/decompression library. It does not aim for maximum compression, or compatibility with any other compression library; instead, it aims for very high speeds and reasonable compression. For instance, compared to the fastest mode of zlib, Snappy is an order of magnitude faster for most inputs, but the resulting compressed files are anywhere from 20% to 100% bigger. (For more information, see "Performance", below.) Snappy has previously been called "Zippy" in some Google presentations and the like. Typical compression ratios (based on the benchmark suite) are about 1.5-1.7x for plain text, about 2-4x for HTML, and of course 1.0x for JPEGs, PNGs and other already-compressed data. Similar numbers for zlib in its fastest mode are 2.6-2.8x, 3-7x and 1.0x, respectively. More sophisticated algorithms are capable of achieving yet higher compression rates, although usually at the expense of speed. Of course, compression ratio will vary significantly with the input. Although Snappy should be fairly portable, it is primarily optimized for 64-bit x86-compatible processors, and may run slower in other environments. In particular: Snappy uses 64-bit operations in several places to process more data at once than would otherwise be possible. Snappy assumes unaligned 32 and 64-bit loads and stores are cheap. On some platforms, these must be emulated with single-byte loads and stores, which is much slower. Snappy assumes little-endian throughout, and needs to byte-swap data in several places if running on a big-endian platform. Experience has shown that even heavily tuned code can be improved. Performance optimizations, whether for 64-bit x86 or other platforms, are of course most welcome; see "Contact", below. You need the CMake version specified in CMakeLists.txt or later to build: Note that Snappy, both the implementation and the main interface, is written in C++. However, several third-party bindings to other languages are available; see the home page for more information. Also, if you want to use Snappy from C code, you can use the included C bindings in snappy-c.h. To use Snappy from your own C++ program, include the file "snappy.h" from your calling file, and link against the compiled library. There are other interfaces that are more flexible in various ways, including support for custom (non-array) input sources. See the header file for more information. When you compile Snappy, the following binaries are compiled in addition to the library itself. You do not need them to use the compressor from your own library, but they are useful for Snappy development. snappy benchmark contains microbenchmarks used to tune compression and decompression performance. snappy unittests contains unit tests, verifying correctness on your machine in various scenarios. snappy test tool can benchmark Snappy against a few other compression libraries (zlib, LZO, LZF, and QuickLZ), if they were detected at configure time. To benchmark using a given file, give the compression algorithm you want to test Snappy against (e.g. --zlib) and then a list of one or more file names on the command line. If you want to change or optimize Snappy, please run the tests and benchmarks to verify you have not broken anything. The testdata/ directory contains the files used by the microbenchmarks, which should provide a reasonably balanced starting point for benchmarking. (Note that baddata[1-3].snappy are not intended as benchmarks; they are used to verify correctness in the presence of corrupted data in the unit test.) 1. C++11 2. Clang (gcc and MSVC are best-effort). 3. Low level optimizations (e.g. assembly or equivalent intrinsics) for: x86 x86-64 ARMv7 (32-bit) ARMv8 (AArch64) 4. Supports only the Snappy compression scheme as described in format description.txt. 5. CMake for building Snappy is distributed through GitHub. For the latest version and other information, see

Excerpt from the source-code README · 6,693 chars · not written by Vinony

Wikidata facts

Official website
google.github.io/snappy
Show 4 more facts
source code repository URL
github.com/google/snappy
software version identifier
1.2.2
publication date
2011-03-18
Sources (7)

via Wikidata · CC0

Available in 8 languages

via Wikidata sitelinks · CC0

Connections

Categories