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

RFC: Callbacks for ByteStream and SdkBody #1307

Merged
merged 17 commits into from
Apr 15, 2022
Merged

Conversation

Velfi
Copy link
Contributor

@Velfi Velfi commented Apr 6, 2022

Motivation and Context

This RFC demonstrates how we could add callback that get triggered when reading chunks from a ByteStream or SdkBody. The RFC also contains one example of how we could use these callbacks to implement a checksum validator for requests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Velfi Velfi requested a review from a team as a code owner April 6, 2022 15:30
@github-actions
Copy link

github-actions bot commented Apr 6, 2022

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Apr 6, 2022

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Server Test

Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start!

design/src/rfcs/rfc0012_bytestream_callback_api.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_bytestream_callback_api.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_bytestream_callback_api.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_bytestream_callback_api.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_bytestream_callback_api.md Outdated Show resolved Hide resolved
update: Arc callbacks instead of boxing them
remove: most bounds from ByteStreamReadCallback trait
add: PartialEq/Eq impl for Inner that disregards callback list
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 6, 2022
@github-actions
Copy link

github-actions bot commented Apr 6, 2022

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Server Test

@github-actions
Copy link

github-actions bot commented Apr 6, 2022

A new doc preview is ready to view.

Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to do some refactoring to SdkBody/ByteStream. As it stands, on the request side, we quickly call into_inner on the ByteStream prior to passing it into the Hyper—this means that the checksumming can't be solely inside of ByteStream (or we need to have ByteStream impl Body directly?

Perhaps we should just teach SdkBody about the callbacks, albeit, through a private interface?

There's a lot of design options here, probably some prototyping is required.

design/src/rfcs/rfc0012_bytestream_callback_api.md Outdated Show resolved Hide resolved
@Velfi Velfi changed the title add: initial draft of bytestream callback RFC RFC: Read callbacks for ByteStream and SdkBody Apr 11, 2022
design/src/rfcs/rfc0012_body_callback_apis.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_body_callback_apis.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_body_callback_apis.md Outdated Show resolved Hide resolved
@Velfi Velfi changed the title RFC: Read callbacks for ByteStream and SdkBody RFC: Callbacks for ByteStream and SdkBody Apr 14, 2022
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 14, 2022
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 14, 2022
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 14, 2022
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 14, 2022
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 14, 2022
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Rust Wrk benchmark report:

Duration: 90 sec, Connections: 32, Threads: 2

Measurement Deviation Current Old
Requests/sec 1.41% 81135.86 80009.25
Total requests 1.35% 7305457 7208067
Total errors NaN% 0 0
Total successes 1.35% 7305457 7208067
Average latency ms 0.78% 1.29 1.28
Minimum latency ms 0.00% 0.02 0.02
Maximum latency ms 1.96% 24.98 24.5
Stdev latency ms 1.36% 2.24 2.21
Transfer Mb 1.35% 759.41 749.28
Connect errors NaN% 0 0
Read errors NaN% 0 0
Write errors NaN% 0 0
Status errors (not 2xx/3xx) NaN% 0 0
Timeout errors NaN% 0 0

Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

design/src/rfcs/rfc0012_body_callback_apis.md Outdated Show resolved Hide resolved
@Velfi Velfi enabled auto-merge (squash) April 15, 2022 16:35
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Rust Wrk benchmark report:

Duration: 90 sec, Connections: 32, Threads: 2

Measurement Deviation Current Old
Requests/sec 4.29% 63996.71 61362.77
Total requests 4.27% 5762313 5526362
Total errors NaN% 0 0
Total successes 4.27% 5762313 5526362
Average latency ms 25.81% 0.78 0.62
Minimum latency ms 0.00% 0.02 0.02
Maximum latency ms -30.21% 19.84 28.43
Stdev latency ms 58.11% 1.17 0.74
Transfer Mb 4.27% 599 574.47
Connect errors NaN% 0 0
Read errors NaN% 0 0
Write errors NaN% 0 0
Status errors (not 2xx/3xx) NaN% 0 0
Timeout errors NaN% 0 0

@Velfi Velfi disabled auto-merge April 15, 2022 17:18
Comment on lines 23 to 26
/// This callback is called once all chunks have been read. If the callback encountered 1 or more errors
/// while running `update`s, this is how those errors are raised. Implementors may return a [`HeaderMap`][HeaderMap]
/// that will be appended to the HTTP body as a trailer. This is only useful to do for streaming requests.
fn trailers(&self) -> Result<Option<HeaderMap<HeaderValue>>, BoxError> { Ok(None) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for SdkBody I can have it inspect itself and only append trailers if the inner variant is Inner::Streaming but I'm not sure that covers every streaming request case.

Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

design/src/rfcs/rfc0012_body_callback_apis.md Outdated Show resolved Hide resolved
design/src/rfcs/rfc0012_body_callback_apis.md Outdated Show resolved Hide resolved
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Rust Wrk benchmark report:

Duration: 90 sec, Connections: 32, Threads: 2

Measurement Deviation Current Old
Requests/sec 12.71% 83126.96 73753.27
Total requests 12.79% 7488692 6639767
Total errors NaN% 0 0
Total successes 12.79% 7488692 6639767
Average latency ms 37.29% 0.81 0.59
Minimum latency ms 0.00% 0.02 0.02
Maximum latency ms 21.58% 20.96 17.24
Stdev latency ms 78.75% 1.43 0.8
Transfer Mb 12.78% 778.45 690.21
Connect errors NaN% 0 0
Read errors NaN% 0 0
Write errors NaN% 0 0
Status errors (not 2xx/3xx) NaN% 0 0
Timeout errors NaN% 0 0

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Rust Wrk benchmark report:

Duration: 90 sec, Connections: 32, Threads: 2

Measurement Deviation Current Old
Requests/sec -9.17% 58213.25 64086.89
Total requests -9.17% 5244326 5773582
Total errors NaN% 0 0
Total successes -9.17% 5244326 5773582
Average latency ms -13.70% 0.63 0.73
Minimum latency ms 0.00% 0.02 0.02
Maximum latency ms -24.32% 16.49 21.79
Stdev latency ms -38.24% 0.63 1.02
Transfer Mb -9.17% 545.15 600.17
Connect errors NaN% 0 0
Read errors NaN% 0 0
Write errors NaN% 0 0
Status errors (not 2xx/3xx) NaN% 0 0
Timeout errors NaN% 0 0

@Velfi Velfi merged commit 699e289 into main Apr 15, 2022
@Velfi Velfi deleted the rfc/bytestream-read-callbacks branch April 15, 2022 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants