Skip to content

Use Unpooled in StreamedRequest#onNext #1136

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

Merged
merged 5 commits into from
Mar 19, 2019
Merged

Conversation

dagnir
Copy link
Contributor

@dagnir dagnir commented Mar 15, 2019

Description

the onNext method can be called from a non SDK owned thread, and if we allocate
the ByteBuf using the pooling allocator, then we pollute the customer's thread
with a ThreadLocal.

Using Unpooled#wrappedBuffer avoids actually copying the arrays so this should
be more performant as well.

Motivation and Context

Fixes #1133

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

the onNext method can be called from a non SDK owned thread, and if we allocate
the ByteBuf using the pooling allocator, then we pollute the customer's thread
with a ThreadLocal.

Using Unpooled#wrappedBuffer avoids actually copying the arrays so this should
be more performant as well.

Fixes aws#1133
@codecov-io
Copy link

codecov-io commented Mar 15, 2019

Codecov Report

Merging #1136 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1136      +/-   ##
============================================
- Coverage     58.77%   58.75%   -0.03%     
+ Complexity     4557     4556       -1     
============================================
  Files           742      742              
  Lines         22941    22895      -46     
  Branches       1713     1707       -6     
============================================
- Hits          13483    13451      -32     
+ Misses         8770     8754      -16     
- Partials        688      690       +2
Impacted Files Coverage Δ Complexity Δ
.../http/nio/netty/internal/NettyRequestExecutor.java 64.24% <100%> (-0.4%) 29 <0> (ø)
...nio/netty/internal/OldConnectionReaperHandler.java 81.81% <0%> (-9.1%) 12% <0%> (-1%)
...awssdk/codegen/poet/client/specs/ProtocolSpec.java 81.25% <0%> (-3.75%) 11% <0%> (ø)
...mazon/awssdk/core/internal/retry/RetryHandler.java 79.54% <0%> (-2.28%) 11% <0%> (ø)
.../amazon/awssdk/http/apache/ProxyConfiguration.java 40.38% <0%> (-1.13%) 16% <0%> (ø)
...wssdk/http/nio/netty/internal/ResponseHandler.java 62.58% <0%> (-0.48%) 15% <0%> (ø)
...awssdk/regions/internal/util/EC2MetadataUtils.java 22.9% <0%> (-0.43%) 8% <0%> (ø)
...mazon/awssdk/protocols/ion/internal/IonParser.java 76.42% <0%> (-0.29%) 67% <0%> (ø)
...re/amazon/awssdk/http/apache/ApacheHttpClient.java 63.97% <0%> (-0.23%) 17% <0%> (ø)
...ttp/pipeline/stages/MakeAsyncHttpRequestStage.java 80.21% <0%> (-0.22%) 14% <0%> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f5ae80...eb940bd. Read the comment docs.

Copy link
Contributor

@spfink spfink left a comment

Choose a reason for hiding this comment

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

Any testing we can add here?

@dagnir
Copy link
Contributor Author

dagnir commented Mar 15, 2019

@spfink Can't think of a good one. This avoids creating the ThreadLocal(s) used by the memory pooling mechanism in Netty so ideally we would check that they aren't created but not sure how besides using reflection to to get the TreadLocal instance and calling get()...

@dagnir dagnir merged commit 62485f9 into aws:master Mar 19, 2019
@dagnir dagnir deleted the use-unpooled branch November 17, 2020 20:53
aws-sdk-java-automation added a commit that referenced this pull request Jan 5, 2021
…62fed70f4

Pull request: release <- staging/cd627411-16db-438d-b2f7-69162fed70f4
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.

Avoid allocating ByteBuf's on non-SDK threads
3 participants