Skip to content

Conversation

landonxjames
Copy link
Contributor

@landonxjames landonxjames commented Aug 1, 2025

Motivation and Context

Continuing the work started in #4208, the new feature we are utilizing is explained in https://blog.rust-lang.org/inside-rust/2025/07/15/call-for-testing-hint-mostly-unused

Description

Add a new ManifestHintsDecorator that allows adding a [hints] section to a generated Cargo.toml. This also introduces a new optional entry in smithy-build.json, hintsMostlyUnusedList that allows indicating which crates this should be enabled for. Currently this is only enabled for aws-sdk-s3, aws-sdk-dynamodb, and aws-sdk-ec2.

Testing

I tested both debug and release builds of the crates, with and without the hint on an M1 Macbook Pro. You can see the full data below, but the general outcome is that release builds are ~50% faster with the hint and debug builds are ~40% faster. A release build of the aws-sdk-ec2 crate went from 124.1s without the hint to 59.1s with it.

Expand To See Test Data

All tests run after deleting the `target/` dir

Debug No Hint

cargo build --timings

||Unit|Total|Codegen|Features|
|---|---|---|---|---|
|1.|aws-sdk-ec2 v0.0.0-local|104.8s|27.9s (27%)|default, default-https-client, rt-tokio, rustls|
|2.|aws-lc-sys v0.30.0 build script (run)|26.1s||prebuilt-nasm|
|3.|aws-sdk-s3 v0.0.0-local|21.2s|5.2s (24%)|default, default-https-client, rt-tokio, rustls, sigv4a|
|4.|aws-sdk-dynamodb v0.0.0-local|13.7s|4.0s (29%)|default, default-https-client, rt-tokio, rustls|
Unit Total Codegen
aws-sdk-ec2 104.8s 27.9s (27%)
aws-sdk-s3 21.2s 5.2s (24%)
aws-sdk-dynamodb 13.7s 4.0s (29%)

Debug Hint

cargo +nightly -Zprofile-hint-mostly-unused build --timings

||Unit|Total|Codegen|Features|
|---|---|---|---|---|
|1.|aws-sdk-ec2 v0.0.0-local|66.4s|2.4s (4%)|default, default-https-client, rt-tokio, rustls|
|2.|aws-lc-sys v0.30.0 build script (run)|25.0s||prebuilt-nasm|
|3.|aws-sdk-s3 v0.0.0-local|14.6s|0.8s (5%)|default, default-https-client, rt-tokio, rustls, sigv4a|
|4.|aws-sdk-dynamodb v0.0.0-local|9.1s|0.4s (4%)|default, default-https-client, rt-tokio, rustls|
Unit Total Codegen
aws-sdk-ec2 66.4s 2.4s (4%)
aws-sdk-s3 14.6s 0.8s (5%)
aws-sdk-dynamodb 9.1s 0.4s (4%)

Release No Hint

cargo build --timings --release

||Unit|Total|Codegen|Features|
|---|---|---|---|---|
|1.|aws-sdk-ec2 v0.0.0-local|124.1s|54.3s (44%)|default, default-https-client, rt-tokio, rustls|
|2.|aws-lc-sys v0.30.0 build script (run)|34.3s||prebuilt-nasm|
|3.|aws-sdk-s3 v0.0.0-local|28.5s|11.4s (40%)|default, default-https-client, rt-tokio, rustls, sigv4a|
|4.|aws-sdk-dynamodb v0.0.0-local|19.3s|8.5s (44%)|default, default-https-client, rt-tokio, rustls|
Unit Total Codegen
aws-sdk-ec2 124.1s 54.3s (44%)
aws-sdk-s3 28.5s 11.4s (40%)
aws-sdk-dynamodb 19.3s 8.5s (44%)

Release Hint

cargo +nightly -Zprofile-hint-mostly-unused build --timings --release

||Unit|Total|Codegen|Features|
|---|---|---|---|---|
|1.|aws-sdk-ec2 v0.0.0-local|59.1s|1.0s (2%)|default, default-https-client, rt-tokio, rustls|
|2.|aws-lc-sys v0.30.0 build script (run)|34.4s||prebuilt-nasm|
|3.|aws-sdk-s3 v0.0.0-local|14.7s|0.4s (3%)|default, default-https-client, rt-tokio, rustls, sigv4a|
|4.|tokio v1.47.1|11.1s|7.3s (65%)|bytes, default, fs, full, io-std, io-util, libc, macros, mio, net, parking_lot, process, rt, rt-multi-thread, signal, signal-hook-registry, socket2, sync, time, tokio-macros|
|5.|aws-sdk-dynamodb v0.0.0-local|10.4s|0.4s (4%)|default, default-https-client, rt-tokio, rustls|
Unit Total Codegen
aws-sdk-ec2 59.1s 1.0s (2%)
aws-sdk-s3 14.7s 0.4s (3%)
aws-sdk-dynamodb 10.4s 0.4s (4%)

Checklist

  • 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.
  • 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.

@@ -17,6 +17,14 @@ fun ClientCodegenDecorator.onlyApplyTo(serviceId: String): List<ClientCodegenDec
},
)

/** Only apply this decorator to the given list of service IDs */
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 didn't end up needing this after I moved the service list to gradle.properties, but seemed like it could be a useful utility in the future, so I left it.

Copy link

github-actions bot commented Aug 1, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

github-actions bot commented Aug 1, 2025

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@landonxjames landonxjames marked this pull request as ready for review August 1, 2025 21:06
@landonxjames landonxjames requested review from a team as code owners August 1, 2025 21:06
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.

Excited to get this out the door!

BTW, people have also complained about aws-sdk-ssm in this issue. Should we consider adding it to the list of services?

@landonxjames
Copy link
Contributor Author

landonxjames commented Aug 1, 2025

Looks like this comment has a pretty good list, if we all feel comfortable with it I can add:

  • aws-sdk-ssm
  • aws-sd-cloudformation
  • aws-sdk-sns
  • aws-sdk-sqs

To the existing list

@landonxjames
Copy link
Contributor Author

landonxjames commented Aug 2, 2025

Added the discussed crates in 550bc3f, will do some quick bench marks on them to make sure it is beneficial.

The failing action (for generating diffs) has the error:

e: file:///home/build/workspace/smithy-rs/codegen-server/typescript/src/main/kotlin/software/amazon/smithy/rust/codegen/server/typescript/smithy/generators/TsServerEnumGenerator.kt:48:9 No value passed for parameter 'customizations'

Which makes me think it might be related to #4039 that was merged earlier today. Checking that PR it seems like the diff isn't generated for the CI run on forks, so CI there wouldn't have caught it.

@joshtriplett
Copy link
Contributor

I would suggest also adding aws-sdk-sts.

Without the hint, a crate depending on aws-sdk-sts built in 41.26s.
With the hint, the same crate built in 36.30s.

Copy link

github-actions bot commented Aug 4, 2025

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link

github-actions bot commented Aug 4, 2025

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@landonxjames landonxjames merged commit 1edaa7e into main Aug 4, 2025
45 checks passed
@landonxjames landonxjames deleted the landonxjames/hint branch August 4, 2025 21:39
aws.services=
aws.services.hints.mostlyUnused=\
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to remove this.

landonxjames added a commit that referenced this pull request Aug 5, 2025
landonxjames added a commit that referenced this pull request Aug 5, 2025
## Motivation and Context
<!--- 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 -->

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->


----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
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