dskit
dskit copied to clipboard
Adding GRPC S2 compression implementation
What this PR does:
Adding S2 compression into GRPC encoding.
Which issue(s) this PR fixes:
Fixes #8522
Checklist
- [x] Tests updated
- [x]
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]
Implementation mostly taken from https://github.com/mostynb/go-grpc-compression/blob/main/internal/s2/s2.go Also added snappy grpc compression benchmark, to match with S2:
goos: darwin
goarch: arm64
pkg: github.com/grafana/dskit/grpcencoding/s2
cpu: Apple M1
BenchmarkS2SCompress-8 249318 4038 ns/op
BenchmarkS2Decompress-8 9593479 120.8 ns/op
BenchmarkS2GrpcCompressionPerf-8 9314 120118 ns/op
PASS
ok github.com/grafana/dskit/grpcencoding/s2 4.409s
goos: darwin
goarch: arm64
pkg: github.com/grafana/dskit/grpcencoding/snappy
cpu: Apple M1
BenchmarkSnappyCompress-8 373032 2785 ns/op
BenchmarkSnappyDecompress-8 5234221 250.9 ns/op
BenchmarkSnappyGrpcCompressionPerf-8 12583 93050 ns/op
PASS
ok github.com/grafana/dskit/grpcencoding/snappy 7.214s
Looks as if you need to run go mod tidy.
I got some more feedback from @pstibrany, we might want to support S2 directly in Mimir instead of going via dskit (to avoid bloating dskit's dependencies). Could you open a (draft?) PR to Mimir, so we can try to come up with a solution there? Thanks!
Sure, let me do that
@aknuds1 : not sure how to do that on Mimir level, will try to do that tomorrow. But btw, which dependencies increase are you talking about? I didn't add new modules, s2 already included in klauspost compress repo. I see only minor upgrade, which IMO should be done anyway.
not sure how to do that on Mimir level, will try to do that tomorrow.
What @pstibrany suggests is to add a dskit extension point, to allow configuring a custom compression type from Mimir.
If you just open a draft Mimir PR depending on this dskit branch, I'll help you shape it into something acceptable :) It's easier for me to see how to do it when I have a Mimir PR.
Looks as if you need to run
go mod tidy.
Ah, for example app. Just did, together with rebase.
If you just open a draft Mimir PR depending on this dskit branch, I'll help you shape it into something acceptable :) It's easier for me to see how to do it when I have a Mimir PR.
Sure, I can do that. I didn't do that before because latest Mimir was not compatible with latest dskit, let me try one more time.
I created 2 special branches in dskit for 2.12.0 ans 2.13.0 releases, based on corresponding dskit commits:
- https://github.com/deniszh/dskit/tree/dzhdanov/grpc-comp-mimir-2.12.0
- https://github.com/deniszh/dskit/tree/dzhdanov/grpc-comp-mimir-2.13.0 and then created 2 patched branches for Mimir
- https://github.com/deniszh/mimir/tree/2.12.0-grpc-s2
- https://github.com/deniszh/mimir/tree/2.13.0-grpc-s2 which just contain repointing Mimir to my dskit.
Opened draft PR - https://github.com/grafana/mimir/pull/9292
I still think it can be useful in different projects, but it's only feeling, I didn't test it. So, can be closed.