Question: snappy compression on large data is not compressed, and message size enlarged by 7 bytes. #856
-
Our service uses the After the compression, we found that the message size is enlarged by around 7 bytes for all messages, and the original data content is not compressed. The original data: Then we use the Question: The original data is not compressed, is this by design or an unexpected behavior ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It looks that the data is seemed as not compressible since |
Beta Was this translation helpful? Give feedback.
-
What do you mean by "reasonable", the
What is the difference between the It looks like the Will the |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply and detailed explanation, I got it. It's by design that
|
Beta Was this translation helpful? Give feedback.
Let's go through my answer.
dstLimit := len(src) - len(src)>>5 - 5
describes the maximum output size before we reject the compression.If you are unfamiliar with bit shifting, it can also be written as:
dstLimit := len(src) - (len(src)/32) - 5
.This means that the limit is "the size if the input" minus "the size divided by 32", minus 5.
Take an input of 1000 bytes. We then replace and it becomes dstLimit = 1000 - (1000/32 = 31) - 5 = 964. If we get to or exceed this limit, we emit the block as uncompressed.
For
best
, the limit is 1000-5 = 995 bytes.