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

Use exact size, if known, to allocate decompression buffer #3048

Merged
merged 5 commits into from Oct 4, 2019

Commits on Sep 27, 2019

  1. Use exact size, if known, to allocate decompression buffer

    For large messages this generates far less garbage than ioutil.ReadAll().
    
    Implement for gzip - RFC1952 requires it, and the Go implementation
    checks it already (modulo 2^32).
    
    Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
    bboreham committed Sep 27, 2019
    Copy the full SHA
    4d7f286 View commit details
    Browse the repository at this point in the history

Commits on Sep 28, 2019

  1. Simplify DecompressedSize()

    Return -1 instead of an error in the case that we can't determine a size.
    
    Use a LimitReader set to size+1 so we can detect cases like corrupt
    messages and overflow of the 32-bit size field.
    
    Signed-off-by: Bryan Boreham <bryan@weave.works>
    bboreham committed Sep 28, 2019
    Copy the full SHA
    7384879 View commit details
    Browse the repository at this point in the history
  2. Define CompressorSizer in comments rather than a named interface

    Based on review feedback
    
    Signed-off-by: Bryan Boreham <bryan@weave.works>
    bboreham committed Sep 28, 2019
    Copy the full SHA
    08ec715 View commit details
    Browse the repository at this point in the history

Commits on Oct 4, 2019

  1. Treat DecompressedSize() as an estimate

    Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
    bboreham committed Oct 4, 2019
    Copy the full SHA
    57a5195 View commit details
    Browse the repository at this point in the history
  2. Use make() instead of buf.Grow()

    It's simpler.
    
    Signed-off-by: Bryan Boreham <bryan@weave.works>
    bboreham committed Oct 4, 2019
    Copy the full SHA
    5e9af82 View commit details
    Browse the repository at this point in the history