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

[improve][misc] Optimize TLS performance by omitting extra buffer copies #23115

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Aug 1, 2024

Motivation

In Pulsar, there has been a long time workaround (#2464) for a Netty SslHandler issue where the input ByteBuf instances get mutated. After Netty 4.1.111.Final, it's no longer necessary to make buffer copies when TLS is enabled. This change on Netty side netty/netty#14086 contains the fix.

Modifications

Since the Pulsar client might get used with an older Netty version, it's necessary to detect that the Netty version contains the fix. The simplest way to detect Netty 4.1.111.Final is by checking for existence of the class io.netty.handler.ssl.SslHandlerCoalescingBufferQueue since that class was extracted from an inner class in 4.1.111.Final.

Instead of referencing ByteBufPair.ENCODER and ByteBufPair.COPYING_ENCODER directly, use ByteBufPair.getEncoder(tlsEnabled) to choose the correct encoder. The COPYING_ENCODER will only be used if an older Netty version is detected. This could be the case when a client application uses the pulsar-client-original maven dependency and the application uses an older Netty version.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

After Netty 4.1.111.Final, it's no longer necessary to make buffer copies when TLS is enabled.
netty/netty#14086 contains the fix
@lhotari lhotari added this to the 3.4.0 milestone Aug 1, 2024
@lhotari lhotari self-assigned this Aug 1, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 1, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 73.44%. Comparing base (bbc6224) to head (937b3e3).
Report is 486 commits behind head on master.

Files Patch % Lines
...org/apache/pulsar/common/protocol/ByteBufPair.java 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23115      +/-   ##
============================================
- Coverage     73.57%   73.44%   -0.13%     
- Complexity    32624    33229     +605     
============================================
  Files          1877     1919      +42     
  Lines        139502   144113    +4611     
  Branches      15299    15746     +447     
============================================
+ Hits         102638   105844    +3206     
- Misses        28908    30158    +1250     
- Partials       7956     8111     +155     
Flag Coverage Δ
inttests 27.83% <72.72%> (+3.24%) ⬆️
systests 24.73% <72.72%> (+0.40%) ⬆️
unittests 72.52% <72.72%> (-0.32%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ulsar/broker/service/PulsarChannelInitializer.java 95.00% <100.00%> (ø)
...e/pulsar/client/impl/PulsarChannelInitializer.java 91.26% <100.00%> (+0.08%) ⬆️
...org/apache/pulsar/common/protocol/ByteBufPair.java 78.84% <57.14%> (-21.16%) ⬇️

... and 519 files with indirect coverage changes

@lhotari lhotari merged commit 1db3c5f into apache:master Aug 6, 2024
54 of 56 checks passed
lhotari added a commit that referenced this pull request Aug 6, 2024
lhotari added a commit that referenced this pull request Aug 6, 2024
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 8, 2024
…ies (apache#23115)

(cherry picked from commit 1db3c5f)
(cherry picked from commit 6b68e9e)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 12, 2024
…ies (apache#23115)

(cherry picked from commit 1db3c5f)
(cherry picked from commit 6b68e9e)
Denovo1998 pushed a commit to Denovo1998/pulsar that referenced this pull request Aug 17, 2024
grssam pushed a commit to grssam/pulsar that referenced this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants