Skip to content
Unverified Commit f6a4514a authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Preallocate correct-sized buffer for event stream (#4212)

## Motivation and Context

Currently when serializing event streams, an empty buffer is used. This
results in repeated reallocations as the buffer grows. However, we can
actually precalculate the exact size that is required.


<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->

## Description
<!--- Describe your changes in detail -->

This PR does two things:
1. Add a MessageSizeHint that aws-smithy-http can use to determine the
in-memory serialized size of the message
2. Add a benchmark of write_message. The benchmark includes an prototype
optimized implementation that we can switch to at a later date.

## Testing
- Benchmark
- Test of correctness for size calculation

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] For changes to the smithy-rs codegen or runtime crates, I have
created a changelog entry Markdown file in the `.changelog` directory,
specifying "client," "server," or both in the `applies_to` key.
- [x] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 685c31c7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment