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._
Loading
Please sign in to comment