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

compress/flate: add Reset method to let callers avoid garbage #6138

Closed
bradfitz opened this issue Aug 13, 2013 · 9 comments
Closed

compress/flate: add Reset method to let callers avoid garbage #6138

bradfitz opened this issue Aug 13, 2013 · 9 comments

Comments

@bradfitz
Copy link
Contributor

Related to issue #6136, flate.NewWriter generates a lot of garbage which can't be
controlled by the calling application.

Options:

-- internal memory reuse in the flate package
-- Reset method (like bufio.Reader and bufio.Writer)
-- let buffers be passed in

Attachments:

  1. k0EYnXJ_LT.0.svg (15027 bytes)
@bradfitz
Copy link
Contributor Author

Comment 1:

Each call to flate.NewWriter allocates 1.4 MB of memory, and Close doesn't reuse any of
it.

@rsc
Copy link
Contributor

rsc commented Aug 13, 2013

Comment 2:

Reset method please.
(Rationale: Having the reset method means that the buffer is attached to the Writer, not
magically moving around, so it gives the caller more control and also keeps the reuse
local to a specific package.)

@rsc
Copy link
Contributor

rsc commented Aug 13, 2013

Comment 3:

I wish it did generate a "log of garbage". That would make things easier.

@bradfitz
Copy link
Contributor Author

Comment 4:

This issue was updated by revision c7d352c.

TestOver65kFiles spends all its time garbage collecting.
Removing the 1.4 MB of allocations per each of the 65k
files brings this from 34 seconds to 0.23 seconds.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12894043

@robpike
Copy link
Contributor

robpike commented Aug 16, 2013

Comment 5:

Looks fixed to me. Reopen if you disagree.

Status changed to Fixed.

@bradfitz
Copy link
Contributor Author

Comment 6:

Per comment #2, this bug focused to be about adding a Reset method on flate.Writer so
callers can avoid 1.4 MB of garbage per writer if it affects them.

Owner changed to @bradfitz.

Status changed to Accepted.

@remyoudompheng
Copy link
Contributor

Comment 7:

Should we create separate issues for compress/zlib and compress/gzip ? Most people never
use compress/flate directly, and the most common demand is probably Resetting a
gzip.Writer.

@remyoudompheng
Copy link
Contributor

Comment 8:

This issue was closed by revision f5f0e40.

Status changed to Fixed.

@bradfitz
Copy link
Contributor Author

Comment 9:

This issue was updated by revision db12f9d.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13435043

@bradfitz bradfitz self-assigned this Aug 30, 2013
@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants