[improve][broker] Make dispatch rate limiter more precise - #18553
Open
poorbarcode wants to merge 1 commit into
Open
[improve][broker] Make dispatch rate limiter more precise#18553poorbarcode wants to merge 1 commit into
poorbarcode wants to merge 1 commit into
Conversation
poorbarcode
force-pushed
the
improve/make_dispatch_limit_more_precise
branch
2 times, most recently
from
November 23, 2022 08:59
9f74a0b to
be27cbd
Compare
4 tasks
poorbarcode
force-pushed
the
improve/make_dispatch_limit_more_precise
branch
2 times, most recently
from
November 23, 2022 16:30
5db855a to
fccd477
Compare
Contributor
|
first of all adding precise terminology in dispatch path is not correct and really misguiding. also have you considered performance impact due to this change? we should not take any performance impact because of this requirement. |
Contributor
Author
|
Hi @rdhabalia
This patch has almost no performance penalty, except that the first time a consumer is created it retrieves a property of another consumer directly from memory |
poorbarcode
force-pushed
the
improve/make_dispatch_limit_more_precise
branch
3 times, most recently
from
December 5, 2022 09:15
a37e875 to
ffd378c
Compare
poorbarcode
force-pushed
the
improve/make_dispatch_limit_more_precise
branch
from
December 15, 2022 20:51
ffd378c to
529a928
Compare
|
The pr had no activity for 30 days, mark with Stale label. |
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
The Dispatch rate limiter serves two purposes:
But the current design has the following problems:
available permitsindicates how many messages the client needs, and then uses the rate limiter to determine how many entries to read. If batch production is not enabled, it is working. When batch production is enabled, the rate limiter counts the number of entries as the number of messages, resulting in excessive entries to be read.In PR #6719,
preciseDispatcherFlowControlwas added to optimize the above problem: If enabledpreciseDispatcherFlowControl, we callavailablePermits / avgMessagesPerEntryto calculate how many entries to read, but this did not solve the problem because that:avgMessagesPerEntry, randomly take a consumer from the subscription, and get attributestat.avgMessagesPerEntry, it is possible to null the property. We should look for the consumer that meets conditionstat.avgMessagesPerEntry != null.Modifications
rate limiter, and then calculate how many entries to read byavgMessagesPerEntryavgMessagesPerEntryfrom the consumers under subscription, if all consumersavgMessagesPerEntryis zero, look up under the topic.calculateToReadofSingle consumer dispatcherandMulti consumer dispatcherinto the parent classAbstractDispatcher, this will save codes.Follow-up PR
After this PR, there are still such scenarios: failing to get
avgMessagesPerEntryresulting in reading excessive messages:avgMessagesPerEntry.The PR below will fix it.
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: