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][broker] Omit making a copy of CommandAck when there are no broker interceptors #18997

Merged

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Dec 20, 2022

Motivation

While fixing a bug, #18987 introduces a performance regression to handleAck method. The copy of the CommandAck instance should only be done if there's a broker interceptor in use.

Modifications

  • Use a null value to indicate that the broker interceptor is missing
  • Make changes to handle the null broker interceptor
  • Omit making a copy of CommandAck in handleAck method when there are no broker interceptors

Documentation

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

Matching PR in forked repository

PR in forked repository: lhotari#114

Copy link
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

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

There are some spots where the NPE is not guarded, for example here:

this.cnx.getBrokerService().getInterceptor()
.onMessagePublish(this, headersAndPayload, messagePublishContext);

@lhotari
Copy link
Member Author

lhotari commented Dec 20, 2022

There are some spots where the NPE is not guarded, for example here:

this.cnx.getBrokerService().getInterceptor()
.onMessagePublish(this, headersAndPayload, messagePublishContext);

Thanks @nicoloboschi, I pushed a fix. PTAL

@lhotari lhotari force-pushed the lh-omit-ack-copy-when-no-broker-interceptors branch from 81f4852 to 1e578c9 Compare December 20, 2022 12:14
@lhotari
Copy link
Member Author

lhotari commented Dec 20, 2022

/pulsarbot rerun-failure-checks

@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2022

Codecov Report

Merging #18997 (1e578c9) into master (22866bd) will decrease coverage by 4.46%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18997      +/-   ##
============================================
- Coverage     45.92%   41.46%   -4.47%     
+ Complexity    10104     2399    -7705     
============================================
  Files           680      235     -445     
  Lines         66758    16652   -50106     
  Branches       7147     1812    -5335     
============================================
- Hits          30660     6904   -23756     
+ Misses        32680     8992   -23688     
+ Partials       3418      756    -2662     
Flag Coverage Δ
unittests 41.46% <ø> (-4.47%) ⬇️

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

Impacted Files Coverage Δ
...g/apache/pulsar/client/impl/ConnectionHandler.java 50.00% <0.00%> (-5.32%) ⬇️
...apache/pulsar/client/impl/AutoClusterFailover.java 69.44% <0.00%> (-0.56%) ⬇️
...n/java/org/apache/pulsar/broker/PulsarService.java
...che/pulsar/broker/intercept/BrokerInterceptor.java
...he/pulsar/broker/intercept/BrokerInterceptors.java
...ava/org/apache/pulsar/broker/service/Producer.java
...pulsar/broker/service/PulsarCommandSenderImpl.java
...va/org/apache/pulsar/broker/service/ServerCnx.java
...g/apache/pulsar/broker/web/PreInterceptFilter.java
...sar/broker/service/plugin/EntryFilterProvider.java
... and 494 more

@lhotari lhotari dismissed nicoloboschi’s stale review December 20, 2022 15:42

review comments addressed

Copy link
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for catching the regression in my earlier PR.

@lhotari lhotari merged commit 1154d0a into apache:master Dec 20, 2022
michaeljmarshall pushed a commit that referenced this pull request Dec 21, 2022
michaeljmarshall pushed a commit that referenced this pull request Dec 21, 2022
…broker interceptors (#18997)

(cherry picked from commit 1154d0a)
(cherry picked from commit b75f068)
michaeljmarshall pushed a commit that referenced this pull request Dec 21, 2022
…broker interceptors (#18997)

(cherry picked from commit 1154d0a)
(cherry picked from commit b75f068)
(cherry picked from commit cc781f7)
@michaeljmarshall michaeljmarshall added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Dec 21, 2022
@michaeljmarshall
Copy link
Member

I cherry-picked to all of the relevant branches. My only concern is that we might end up causing issues for any custom code that runs in the broker. Even though this might break broker extensions, I think it is relevant to cherry pick this change. Otherwise, we're subject to significant performance regressions in most implementations (assuming that most users do not have broker interceptors). Maybe it's sufficient to put a note in the release notes?

@michaeljmarshall
Copy link
Member

Release note: remove BrokerInterceptorDisabled in favor of a null value indicating that the interceptor is disabled.

michaeljmarshall pushed a commit to datastax/pulsar that referenced this pull request Dec 21, 2022
…broker interceptors (apache#18997)

(cherry picked from commit 1154d0a)
(cherry picked from commit b75f068)
(cherry picked from commit cc781f7)
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.

None yet

4 participants