...

Text file src/github.com/klauspost/compress/snappy/xerial/README.md

Documentation: github.com/klauspost/compress/snappy/xerial

     1# go-xerial-snappy
     2
     3Xerial-compatible Snappy framing support for golang.
     4
     5Packages using Xerial for snappy encoding use a framing format incompatible with
     6basically everything else in existence.
     7
     8Apps that use this format include Apache Kafka (see
     9https://github.com/dpkp/kafka-python/issues/126#issuecomment-35478921 for
    10details).
    11
    12# Fork
    13
    14Forked from [github.com/eapache/go-xerial-snappy](https://github.com/eapache/go-xerial-snappy).
    15
    16Changes:
    17
    18* Uses [S2](https://github.com/klauspost/compress/tree/master/s2#snappy-compatibility) for better/faster compression and decompression.
    19* Fixes 0-length roundtrips.
    20* Adds `DecodeCapped`, which allows decompression with capped output size.
    21* `DecodeInto` will decode directly into destination if there is space enough.
    22* `Encode` will now encode directly into 'dst' if it has space enough.
    23* Fixes short snappy buffers returning `ErrMalformed`.
    24* Renames `EncodeStream` to `Encode`.
    25* Adds `EncodeBetter` for better than default compression at ~half the speed.
    26
    27
    28Comparison (before/after):
    29
    30```
    31BenchmarkSnappyStreamEncode-32    	  959010	      1170 ns/op	 875.15 MB/s	    1280 B/op	       1 allocs/op
    32BenchmarkSnappyStreamEncode-32    	 1000000	      1107 ns/op	 925.04 MB/s	       0 B/op	       0 allocs/op
    33--> Output size: 913 -> 856 bytes
    34
    35BenchmarkSnappyStreamEncodeBetter-32    	  477739	      2506 ns/op	 408.62 MB/s	       0 B/op	       0 allocs/op
    36--> Output size: 835 bytes
    37
    38BenchmarkSnappyStreamEncodeMassive-32  	     100    	  10596963 ns/op	 966.31 MB/s	   40977 B/op	       1 allocs/op
    39BenchmarkSnappyStreamEncodeMassive-32  	     100       	  10220236 ns/op	1001.93 MB/s	       0 B/op	       0 allocs/op
    40--> Output size: 2365547 -> 2256991 bytes
    41
    42BenchmarkSnappyStreamEncodeBetterMassive-32    	      69	  16983314 ns/op	 602.94 MB/s	       0 B/op	       0 allocs/op
    43--> Output size: 2011997 bytes
    44
    45BenchmarkSnappyStreamDecodeInto-32    	 1887378	       639.5 ns/op	1673.19 MB/s	    1088 B/op	       3 allocs/op
    46BenchmarkSnappyStreamDecodeInto-32    	 2707915	       436.2 ns/op	2452.99 MB/s	       0 B/op	       0 allocs/op
    47
    48BenchmarkSnappyStreamDecodeIntoMassive-32    	     267	   4559594 ns/op	2245.81 MB/s	   71120 B/op	       1 allocs/op
    49BenchmarkSnappyStreamDecodeIntoMassive-32    	     282	   4285844 ns/op	2389.26 MB/s	       0 B/op	       0 allocs/op
    50```

View as plain text