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

Add stateless gzip/deflate #176

Merged
merged 3 commits into from
Nov 12, 2019
Merged

Add stateless gzip/deflate #176

merged 3 commits into from
Nov 12, 2019

Conversation

klauspost
Copy link
Owner

@klauspost klauspost commented Nov 9, 2019

StatelessCompression will do compression but without maintaining any state between Write calls.

There will be no memory kept between Write calls, but compression and speed will be suboptimal.

Because of this, the size of actual Write calls will affect output size.

In gzip, specify level -3 to enable.

For direct deflate use, NewStatelessWriter and StatelessDeflate are available. See https://github.com/klauspost/compress/pull/176/files#diff-a5ae2d33d655db7f26bd8de2b9733ea5R43

A bufio.Writer can of course be used to control write sizes.

StatelessCompression will do compression but without maintaining any state between Write calls.

There will be no memory kept between Write calls, but compression and speed will be suboptimal.

Because of this, the size of actual Write calls will affect output size.
@klauspost
Copy link
Owner Author

@FZambia re our talk.

@vtolstov
Copy link

vtolstov commented Nov 9, 2019

As i see this can be useful for some http wrappers that compress output?

@klauspost
Copy link
Owner Author

klauspost commented Nov 9, 2019

@vtolstov You should just reuse a gzip.Writer. Doing that will not allocate. This will - on every Write. And you need to be able to control how writes are done. Writing one byte at the time = absolutely horrible.

@klauspost klauspost merged commit ba5daf5 into master Nov 12, 2019
@klauspost klauspost deleted the stateless-deflate-gzip branch November 12, 2019 13:44
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.

2 participants