You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pre-allocate response body using Content-Length (#1565)
Updates SDK API client deserialization to pre-allocate byte slice and string
response payloads.
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
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)
* Add changelog
Co-authored-by: Jason Del Ponte <[email protected]>
"description": "Updates SDK API client deserialization to pre-allocate byte slice and string response payloads, [#1565](https://github.com/aws/aws-sdk-go-v2/pull/1565). Thanks to [Tyson Mote](https://github.com/tysonmote) for submitting this PR.",
Copy file name to clipboardExpand all lines: codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/RestJsonProtocolGenerator.java
0 commit comments