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

Pre-allocate response body using Content-Length #1565

Merged
merged 7 commits into from Jan 24, 2022

Commits on Jan 20, 2022

  1. Use response Content-Length to pre-size buffer

    This saves us allocations when the response body is greater than 512
    bytes. For large responses, like multi-megabyte Lambda Invoke responses,
    this can be a very significant number of allocations and slice copies
    because ioutil.ReadAll / io.ReadAll start with 512 bytes and follow
    append's growth rules:
    
    * https://cs.opensource.google/go/go/+/refs/tags/go1.17.6:src/io/io.go;drc=dc289d3dcb59f80b9e23c7e8f237628359d21d92;l=627
    * https://cs.opensource.google/go/go/%20/master:src/runtime/slice.go;l=166?q=growslice
    tysonmote committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    11986fe View commit details
    Browse the repository at this point in the history
  2. make generate format

    tysonmote committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    1928414 View commit details
    Browse the repository at this point in the history
  3. Nicer formatting

    tysonmote committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    3b50ea4 View commit details
    Browse the repository at this point in the history
  4. Update code generation to only add contentLength param when needed an…

    …d limit downcast to bytes usage
    jasdel committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    b2eedf4 View commit details
    Browse the repository at this point in the history
  5. regenerate api clients

    jasdel committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    67873f2 View commit details
    Browse the repository at this point in the history
  6. Adding benchmarks for new pre-allocated buffer

    S3 GetBucketPolicy benchmark:
    
    name                old time/op    new time/op    delta
    GetBucketPolicy-12    12.7ms ± 2%     8.7ms ± 2%  -31.60%  (p=0.000 n=9+9)
    
    name                old alloc/op   new alloc/op   delta
    GetBucketPolicy-12    83.4MB ± 0%    50.4MB ± 0%  -39.60%  (p=0.000 n=10+10)
    
    name                old allocs/op  new allocs/op  delta
    GetBucketPolicy-12       256 ± 0%       216 ± 0%  -15.49%  (p=0.000 n=10+10)
    
    Schemas GetCodeBindingSource benchmarks:
    
    name                     old time/op    new time/op    delta
    GetCodeBindingSource-12    10.8ms ± 3%     7.4ms ± 4%  -31.79%  (p=0.000 n=10+10)
    
    name                     old alloc/op   new alloc/op   delta
    GetCodeBindingSource-12    70.8MB ± 0%    37.8MB ± 0%  -46.64%  (p=0.000 n=10+10)
    
    name                     old allocs/op  new allocs/op  delta
    GetCodeBindingSource-12       241 ± 0%       200 ± 0%  -17.01%  (p=0.000 n=10+10)
    jasdel committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    d95c2dd View commit details
    Browse the repository at this point in the history
  7. Add changelog

    jasdel committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    7b1d966 View commit details
    Browse the repository at this point in the history