-
Notifications
You must be signed in to change notification settings - Fork 265
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
Refine publish notifications #271
base: master
Are you sure you want to change the base?
Refine publish notifications #271
Conversation
@jipanyang @zhenggen-xu As we offline discussed I submit this PR. Please help review. Thanks for your solution and inspiration. #Closed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared with the existing implementation, changes in this PR optimized the processing of notification at Select() of consumerStateTable side.
We need to confirm if it is good enough to cope with the route flapping case seen previously. @zhenggen-xu
common/redisselect.cpp
Outdated
* This is no big harm since all the late messages will be selected and nothing popped | ||
* when the channel is not completely busy. | ||
*/ | ||
n -= m_queueLength; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any usage of "n" after this operation? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It will be optimized out by compiler. It may help readability a little bit.
In reply to: 276422184 [](ancestors = 276422184)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It will be optimized out by compiler. It may help readability a little bit.
In reply to: 276422184 [](ancestors = 276422184)
I think it causes more confusion than helping readability. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* in the select-pop(s) pattern | ||
*/ | ||
if (n <= 0) | ||
n = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what scenario n <= 0?
#Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to prevent any logic error outside the scope of RedisSelect. Considering the case if there are redundant notifications but there is no data popped, caller may call discard(0), and here the function consumes one message in the queue if there is any. discard(negative) is not for protection purpose and should be not in a true case.
In reply to: 276515380 [](ancestors = 276515380)
common/redisselect.cpp
Outdated
* This is no big harm since all the late messages will be selected and nothing popped | ||
* when the channel is not completely busy. | ||
*/ | ||
n -= m_queueLength; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It will be optimized out by compiler. It may help readability a little bit.
In reply to: 276422184 [](ancestors = 276422184)
I think it causes more confusion than helping readability. #Resolved
…() (sonic-net#214)" This reverts commit c5d5434.
Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
40e9e79
to
74778c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
retest this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we made any tests checking the new implementation is faster than previous?
Other as comments
// Override with an empty body, and subclasses will explicitly discard messages in the channel | ||
void ConsumerTableBase::updateAfterRead() | ||
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why do we need this?
The base class already has an empty body
r = cs.isQueueEmpty(); | ||
EXPECT_TRUE(r); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this test was removed?
bool ConsumerTableBase::hasCachedData() | ||
{ | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base class has the same implementation. It doesn't need to be implemented here.
@@ -88,7 +88,7 @@ bool SubscriberStateTable::hasData() | |||
|
|||
bool SubscriberStateTable::hasCachedData() | |||
{ | |||
return m_buffer.size() > 1 || m_keyspace_event_buffer.size() > 1; | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's default implementation in the base class. We could remove whole method.
This is a competing PR to #258
I reverted #214 since it exposed unnecessary implementation details.
Problem statement is same as #258, so I shamelessly copied it here.
The implementation proposed here follows some design principles.