Delphi FastSnappy64

8 august 2016: 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. On a single core of a Core i7 processor in 64-bit mode, Snappy compresses at about 250 MB/sec or more and decompresses at about 500 MB/sec or more. Snappy is widely used inside Google, in everything from BigTable and MapReduce, is useful for higher-level framing and encapsulation of data, e.g. for transporting compressed data across HTTP in a streaming fashion.

These C builds are compiled with LLVM 3.8.1 CLANG for WIN32/WIN64, BCCIOSARM 7.20 for IOS, BCCAARM 7.20 for ANDROID
Provided a basic sample tested with DCC32/DCC64/DCCIOSARM/DCCAARM 31.0, FPC 3.0

Http JSON 50KB TMemoryStream file test
Intel i7 2.6 Ghz CPU, Windows 10 Pro

Snappy 64bit WIN64
compress in 237.33ms, ratio=85%, 1.6 GB/s
uncompress in 92.43ms, 4.3 GB/s

Snappy 32bit WIN32
compress in 269.96ms, ratio=85%, 1.4 GB/s
uncompress in 135.88ms, 2.9 GB/s

Zlib fastest mode 64bit WIN64
compress in 1.77s, ratio=89%, 231.7 MB/s
uncompress in 961.10ms, 427.6 MB/s

Zlib fastest mode 32bit WIN32
compress in 2.12s, ratio=89%, 193.6 MB/s
uncompress in 1.43s, 286.1 MB/s

Using TParallel.For from System.Threading WIN64
Snappy compress in 54.94ms, ratio=85%, 7.3 GB/s
Snappy uncompress in 46.05ms, 8.7 GB/s

Link Delphi FastSnappy64 v.1.1.3
(Link Delphi 7 Snappy 32bit)

Hint: take a look at SnappyJS for the http client side, eg. to uncompress a JSON response; then on the server side you should add a class helper to Web.HTTPApp.TWebResponse (WebBroker) with a method to compress the content stream, so to obtain a complete web compression pipeline.

Feel free to test the above libraries and/or enhance them.

Please check internal comments, thank you.

Contact me at
Roberto Della Pasqua