-
Notifications
You must be signed in to change notification settings - Fork 695
GEODE-9347: optimize pubSub #6814
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
GEODE-9347: optimize pubSub #6814
Conversation
Each Client keeps track of its subscription names in a set. Each server keeps track of all its local subscriptions in a SubscriptionManager. The SubscriptionManager keeps track of Clients subscribed in a ClientSubscriptionManager.
80400d9 to
d845d3b
Compare
jdeppe-pivotal
left a comment
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'm still going over the changes, but wanted to ask these questions so long.
.../src/main/java/org/apache/geode/redis/internal/pubsub/AbstractClientSubscriptionManager.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/geode/redis/internal/pubsub/AbstractClientSubscriptionManager.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/geode/redis/internal/pubsub/AbstractClientSubscriptionManager.java
Outdated
Show resolved
Hide resolved
kirklund
left a comment
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.
Overall looks good, but I really want to see some unit tests for these classes:
- PunsubscribeExecutor
- UnsubscribeExecutor
- Client
- AbstractClientSubscriptionManager
- AbstractSubscription
- AbstractSubscriptionManager
- ChannelSubscriptionManager
- PatternClientSubscriptionManager
- PatternSubscriptionManager
The following classes weren't changed much in this PR, but they really should already have unit
tests (they don't). This PR should at least introduce simple unit tests for what is changed in the
PR. Chores should also be planned to expand coverage on these classes, especially since they are
relatively new:
- GlobPattern
- PingExecutor
- HScanExecutor
- KeysExecutor
- ScanExecutor
- SScanExecutor
- ExecutionHandlerContext
- ChannelSubscription
- PatternSubscription
- PartitionedRegionFunctionExecutor
In particular, ExecutionHandlerContext is a rather large class to not have any unit tests.
...ntegrationTest/java/org/apache/geode/redis/internal/pubsub/SubscriptionsIntegrationTest.java
Outdated
Show resolved
Hide resolved
|
@kirklund Regarding unit tests for the classes you mentioned; a decision was made by the folks who're working on the Geode Redis module to rely predominantly on integration tests to validate the behaviour of the Geode Redis API. Unit tests are used to test components that are not accessible via the API (such as object sizing for rebalance, the internal data structures that back the various RedisData classes etc.) but it was not considered worthwhile to also unit test methods that are covered in their entirety via integration tests. Adding unit tests to the classes you list would represent a fundamental change in testing approach for the group working on the Geode Redis module, and as such, it feels like something that would be better brought to the dev list if it's a change that you feel really needs to be made, since it was originally a deliberate choice rather than an oversight. |
|
@kirklund, thanks for the review. For this PR I'm going to focus on adding unit tests for the new classes and those that had significant changes (for example Client). |
an instance of it to the new PatternClientSubscriptionManager. Now it stores an instance of Pattern obtained from a factory method on GlobPattern. To prevent this mistake from happening in the future, GlobPattern no longer permit instances to be created.
...edis/src/main/java/org/apache/geode/redis/internal/executor/pubsub/PunsubscribeExecutor.java
Outdated
Show resolved
Hide resolved
...redis/src/main/java/org/apache/geode/redis/internal/executor/pubsub/UnsubscribeExecutor.java
Outdated
Show resolved
Hide resolved
...ible-with-redis/src/main/java/org/apache/geode/redis/internal/netty/StringBytesGlossary.java
Show resolved
Hide resolved
.../src/main/java/org/apache/geode/redis/internal/pubsub/AbstractClientSubscriptionManager.java
Outdated
Show resolved
Hide resolved
...le-with-redis/src/main/java/org/apache/geode/redis/internal/pubsub/AbstractSubscription.java
Outdated
Show resolved
Hide resolved
...s-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/pubsub/PubSubImpl.java
Outdated
Show resolved
Hide resolved
...ompatible-with-redis/src/main/java/org/apache/geode/redis/internal/pubsub/Subscriptions.java
Show resolved
Hide resolved
...ompatible-with-redis/src/main/java/org/apache/geode/redis/internal/pubsub/Subscriptions.java
Outdated
Show resolved
Hide resolved
...ntegrationTest/java/org/apache/geode/redis/internal/pubsub/SubscriptionsIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ntegrationTest/java/org/apache/geode/redis/internal/pubsub/SubscriptionsIntegrationTest.java
Outdated
Show resolved
Hide resolved
what subscriptions to drop when the user does not specific, down into the Subscriptions class. This allows the interactions with the client subscription lists to be centralized in Subscriptions instead of it being up in the command executor. So the executor is now simpler and the code is unit tested on Subscriptions.
the interrupt state of the thread
Instead it depends on Client
Before we had one for every Subscription and unsubscribe did not clean them up.
jdeppe-pivotal
left a comment
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.
Nice work Darrel!
kirklund
left a comment
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.
Thanks Darrel!
This is already stored in the key of the top level manager so it was not also needed in the leaf subscription object.
for patterns and one for channels. It is the manager that owns the subscription that determines if it is a pattern or channel.
Client now keeps track of channel and patterns it has subscribed to making it easier to check. This will improve performance of non-pubsub ops when a server has existing subscriptions.
if a client has any subscriptions.
The internal Subscriptions class now uses maps instead of lists. Concurrent maps are used and the synchronization in the pubsub internal implementation has been removed.
Some of the messages have been optimized by sending a canonical byte[] instead of converting a String to a byte[] for every message.
If many clients subscribe to the same pattern, publish will now only need to check that pattern once. The older code checked once per client.
Thank you for submitting a contribution to Apache Geode.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
Has your PR been rebased against the latest commit within the target branch (typically
develop)?Is your initial contribution a single, squashed commit?
Does
gradlew buildrun cleanly?Have you written or updated unit tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Note:
Please ensure that once the PR is submitted, check Concourse for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.