Skip to content

Elevated CPI rate in flate/stateless.go #717

Answered by klauspost
marselester asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, var dst tokens is zeroing.

As the docs state using Stateless compression is only for a very specific use cases, and it doesn't seem your use case covers that. Stateless does not mean no allocations - it means no buffers are kept between writes, so it will allocate more totally, since it has to allocate for every Write.

You are sacrificing both speed and compression by using a stateless compressor. Likely you will see a 2-3x speed up by using a sync.Pool with a gzip encoder at level 1.

I'd recommend the default compression you will not lose as much compression as you currently do. It is still likely to be 2x faster than the old.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by klauspost
Comment options

You must be logged in to vote
2 replies
@klauspost
Comment options

@marselester
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #715 on December 19, 2022 11:54.