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

Feature: Request Compression for operations modeled with the @requestCompression trait #3647

Merged
merged 13 commits into from
May 21, 2024

Conversation

Velfi
Copy link
Contributor

@Velfi Velfi commented May 16, 2024

Motivation and Context

#2891

Description

This PR contains all the changes from the last three compression PRs.

New in this PR:

  • I re-enabled some GZIP protocol tests that were previously disabled.
  • I added changelog entries.

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

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

Velfi and others added 7 commits May 8, 2024 09:26
This adds a new runtime crate. The new crate contains code related to
compressing requests. Not included in this PR is everything needed to
actually make use of the new crate.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
This PR includes all the changes necessary for AWS runtime crates to
support request compression.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
PR 3 of 3. Most of the compression tests happen here since we don't have
a request-compression-supporting model in our set of "smoke test"
service models.

----

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

---------

Co-authored-by: ysaito1001 <[email protected]>
Co-authored-by: Aaron Todd <[email protected]>
@Velfi Velfi requested review from a team as code owners May 16, 2024 15:26
Copy link

Copy link

Copy link

Copy link
Contributor

@landonxjames landonxjames left a comment

Choose a reason for hiding this comment

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

Looks good based on all the previous feature branch reviews.

One question, just curious what was going on with the flaky test?


impl Compress for Gzip {
fn compress_bytes(&mut self, bytes: &[u8], writer: &mut dyn Write) -> Result<(), BoxError> {
Gzip::compress_bytes(self, bytes, writer).map_err(Into::into)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the flate2 gzip implementation deterministic by default? Was reading and it looks like the GNU version is not unless you use -n since it includes a timestamp in the file. Note sure if that really matters for our use-case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was broken b/c I mounted the interceptor twice in codegen and I was doing snapshot testing. Once I removed the extra interceptor things worked fine. As far as I can tell, GZIP is deterministic in CI b/c the tests looking for a specific output are passing. If GZIP wasn't deterministic then we'd have to use a decoder to unzip and then check the contents. I think I do that in the compression crate somewhere.

I'm going to ignore it until it actually fails. LMK if you can think of a good test to add.

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

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

Great work, thank you!

// we check to see if the data is big enough to make compression worthwhile.
if let Some(known_size) = http_body::Body::size_hint(request.body()).exact() {
if known_size < options.min_compression_size_bytes() as u64 {
tracing::trace!("request body is below minimum size and will not be compressed");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also print known_size to add additional info for logging, something like "request body of size {known_size} is below ..." (options.min_compression_size_bytes can also be printed here too) ?

Copy link

@aws-sdk-rust-ci aws-sdk-rust-ci merged commit 27b4d14 into main May 21, 2024
4 checks passed
@aws-sdk-rust-ci aws-sdk-rust-ci deleted the zhessler/request-compression branch May 21, 2024 14:57
Copy link

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.

4 participants