[improve][broker] Improve no-filter dispatch performance by skipping filter calls#26056
Open
void-ptr974 wants to merge 2 commits into
Open
[improve][broker] Improve no-filter dispatch performance by skipping filter calls#26056void-ptr974 wants to merge 2 commits into
void-ptr974 wants to merge 2 commits into
Conversation
ab3f3eb to
08414a3
Compare
08414a3 to
c487ddb
Compare
c487ddb to
ba8c764
Compare
merlimat
approved these changes
Jun 18, 2026
…ilter-fast-path # Conflicts: # pulsar-broker/src/test/java/org/apache/pulsar/broker/service/AbstractBaseDispatcherTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
AbstractBaseDispatcher#filterEntriesForConsumeris on the dispatch hot path. When no entry filters are configured,runFiltersForEntryonly returnsACCEPT, so calling it once per entry is avoidable work.Modifications
runFiltersForEntrywhen no entry filters are configured.Scope
This intentionally leaves the filtered/redelivery list allocation and ack-set handling unchanged. Those are separate optimizations and are kept out of this PR to make the review focused on the no-filter fast path only.
Performance
This improves no-filter dispatch performance by removing one no-op filter call and the REJECT/RESCHEDULE checks per entry when no filters are configured. Allocation remains effectively unchanged; this is a CPU-path optimization.
JMH data gathered locally using a local-only
DispatcherDispatchPathBenchmark.(noFilterRunFiltersPerEntry|noFilterFastPath)benchmark, with-p entriesCount=32,256,1000 -p batchSize=1,10 -wi 2 -i 5 -w 1s -r 1s -f 1 -bm avgt -tu ns -prof gc:Verification
AbstractBaseDispatcherTestcoverage for a 512-entry no-filter dispatch batch with varying payload sizes and batch sizes../gradlew :pulsar-broker:compileJava :pulsar-broker:checkstyleMain --max-workers=1./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.AbstractBaseDispatcherTest --max-workers=1 -PtestRetryCount=0./gradlew :pulsar-broker:checkstyleTest --max-workers=1