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

Reduce initial memory usage by auto-loading bundled gems #3083

Merged
merged 7 commits into from
Aug 8, 2024

Conversation

alextwoods
Copy link
Contributor

Reduce initial memory usage by auto-loading bundled gems (STS, SSO, SSOOIDC).

These gems are used only by certain credential providers in core and are usually not all needed in any given application.

Memory used when requiring aws-sdk-core:

  • BEFORE Total allocated: 22028954 bytes (183674 objects)
  • AFTER Total allocated: 19133824 bytes (161203 objects)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

  1. To make sure we include your contribution in the release notes, please make sure to add description entry for your changes in the "unreleased changes" section of the CHANGELOG.md file (at corresponding gem). For the description entry, please make sure it lives in one line and starts with Feature or Issue in the correct format.

  2. For generated code changes, please checkout below instructions first:
    https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md

Thank you for your contribution!

gems/aws-sdk-core/CHANGELOG.md Outdated Show resolved Hide resolved
gems/aws-sdk-core/lib/aws-sdk-core.rb Outdated Show resolved Hide resolved
@@ -107,10 +107,11 @@ def env_bool key, default
require 'aws-sdk-resources'

# Finally load all of the gems. Core is loaded a second time because of STS.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still relevant? Also I think this gem should be bumped too and it probably needs a minimum core version bump because of that.

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'm not sure it ever was actually correct. I've updated.

aws-sdk-resources will get a version bump because of the codegen changes (removing the autoload for sts,sso,ssoidc).
I don't believe it needs a new minimum core version - with old (current) core versions SSO,STS,SSOOIDC are all explicitly required so the autoload thats being removed would not have done anything.

BuildTools.replace_lines(
filename: "#{$GEMS_DIR}/aws-sdk-resources/lib/aws-sdk-resources.rb",
start: /# service gems/,
stop: /# end service gems/,
new_lines: BuildTools::Services.map { |service|
new_lines: autoload_services.map { |service|
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is core ignored here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a little confusing - this is actually removing the bundled service gems from the autoload. They have a gem name of aws-sdk-core (since they are bundled in it). I've added comments.

@mullermp mullermp merged commit b15b126 into version-3 Aug 8, 2024
31 checks passed
@mullermp mullermp deleted the autoload_core branch August 8, 2024 23:20
mullermp added a commit that referenced this pull request Aug 9, 2024
alextwoods added a commit that referenced this pull request Aug 9, 2024
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.

2 participants