Skip to content

Commit f6a4514

Browse files
authored
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._
1 parent 685c31c commit f6a4514

File tree

8 files changed

+1186
-48
lines changed

8 files changed

+1186
-48
lines changed

.changelog/1752602322.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
applies_to:
3+
- server
4+
- client
5+
- aws-sdk-rust
6+
authors:
7+
- rcoh
8+
references: ["smithy-rs#4212"]
9+
breaking: false
10+
new_feature: false
11+
bug_fix: false
12+
---
13+
Event streams now allocate a right-sized buffer avoiding repeated reallocations during serialization

0 commit comments

Comments
 (0)