Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds configurable compression algorithms for chunks #1411

Merged
merged 22 commits into from
Dec 13, 2019

Conversation

cyriltovena
Copy link
Contributor

@cyriltovena cyriltovena commented Dec 12, 2019

This introduces a new chunk format (v2) that contains the current compression algorithm used to encode the chunk.

Loki can still read (v1) format which are by default gzip, and the new format is now the default with still gzip as encoding.

You can mix multiple encodings over time now, if you want to try different format.

We support those encoding now:

  • gzip: default gzip golang implementation the slowest with the best compression ratio.
  • gzip-1: gzip with best speed configuration, a bit fast but also a lower compression ratio.
  • lz4 : fast compression and decompression speed. (use more memory than snappy)
  • none: no compressoion
  • snappy: the popular google snappy compression format
  • snappyv2: an optimized version of snappy see https://github.com/klauspost/compress/tree/master/s2

Chunk size for each

  --- PASS: TestChunkSize/none (0.01s)
        Chunk size 2.7 MB
       characters  2623262
    --- PASS: TestChunkSize/gzip (0.01s)
        Chunk size 144 kB
        characters  2623262
    --- PASS: TestChunkSize/gzip-1 (0.01s)
         Chunk size 158 kB
        characters  2623262
    --- PASS: TestChunkSize/lz4 (0.00s)
        Chunk size 188 kB
        characters  2623262
    --- PASS: TestChunkSize/snappy (0.00s)
        Chunk size 272 kB
       characters  2623262
    --- PASS: TestChunkSize/snappyv2 (0.00s)
        Chunk size 205 kB
        characters  2623262

Decompression speed benchmark

BenchmarkRead/none-16         	      15	  71535984 ns/op	134484800 B/op	  491005 allocs/op
--- BENCH: BenchmarkRead/none-16 bytes per second  1.8 GB
BenchmarkRead/gzip-16         	       5	 212703812 ns/op	134582374 B/op	  491465 allocs/op
--- BENCH: BenchmarkRead/gzip-16 bytes per second  617 MB
BenchmarkRead/gzip-1-16       	       5	 221152209 ns/op	134588478 B/op	  491452 allocs/op
--- BENCH: BenchmarkRead/gzip-1-16 bytes per second  593 MB
BenchmarkRead/lz4-16          	      10	 100376532 ns/op	141235551 B/op	  491049 allocs/op
--- BENCH: BenchmarkRead/lz4-16  bytes per second  1.3 GB
BenchmarkRead/snappy-16       	      10	 101250653 ns/op	134560112 B/op	  491038 allocs/op
--- BENCH: BenchmarkRead/snappy-16 bytes per second  1.3 GB
BenchmarkRead/snappyv2-16     	      10	 108484452 ns/op	137413780 B/op	  491057 allocs/op
--- BENCH: BenchmarkRead/snappyv2-16 bytes per second  1.2 GB
PASS
ok  	github.com/grafana/loki/pkg/chunkenc	31.598s

Compression speed benchmark

pkg: github.com/grafana/loki/pkg/chunkenc
BenchmarkWrite/none-16         	     754	   2003727 ns/op	 2758437 B/op	      48 allocs/op
BenchmarkWrite/gzip-16         	     106	  10503831 ns/op	  467140 B/op	      98 allocs/op
BenchmarkWrite/gzip-1-16       	     231	   5146374 ns/op	  448971 B/op	      98 allocs/op
BenchmarkWrite/lz4-16          	     427	   2878722 ns/op	  269449 B/op	      58 allocs/op
BenchmarkWrite/snappy-16       	     715	   1721530 ns/op	  750768 B/op	      56 allocs/op
BenchmarkWrite/snappyv2-16     	     296	   5321221 ns/op	10866139 B/op	     158 allocs/op
PASS
ok  	github.com/grafana/loki/pkg/chunkenc	29.111s

cyriltovena and others added 18 commits December 11, 2019 14:05
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
…ing string -> byte conversion.

It also makes code little more readable. We pool those buffers for reuse.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
This helps with reader/buffered reader reuse.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
(mostly to get more understandable profile)

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
pkg/chunkenc/memchunk.go Outdated Show resolved Hide resolved
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
docs/configuration/README.md Outdated Show resolved Hide resolved
pkg/chunkenc/util_test.go Outdated Show resolved Hide resolved
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some new codepaths for me, but looks great.

pkg/ingester/ingester.go Outdated Show resolved Hide resolved
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena cyriltovena merged commit 7654c27 into grafana:master Dec 13, 2019
@cyriltovena cyriltovena deleted the lz4 branch December 13, 2019 21:46
@isavcic
Copy link

isavcic commented Jan 4, 2020

I see zstandard missing from this list, any particular reason?

@cyriltovena
Copy link
Contributor Author

It was there, but the performance were bad so we removed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants