Skip to content

Conversation

@dschneider-pivotal
Copy link
Contributor

@dschneider-pivotal dschneider-pivotal commented Aug 28, 2021

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 build run 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.

@dschneider-pivotal dschneider-pivotal added the redis Issues related to the geode-for-redis module label Aug 28, 2021
@dschneider-pivotal dschneider-pivotal changed the title client now maintains a subscription count GEODE-9347: optimize pubSub Aug 30, 2021
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.
Copy link
Contributor

@jdeppe-pivotal jdeppe-pivotal left a 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.

Copy link
Contributor

@kirklund kirklund left a 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.

@DonalEvans
Copy link
Contributor

@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.

@dschneider-pivotal
Copy link
Contributor Author

@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.
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.
Copy link
Contributor

@jdeppe-pivotal jdeppe-pivotal left a comment

Choose a reason for hiding this comment

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

Nice work Darrel!

Copy link
Contributor

@kirklund kirklund left a 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.
@dschneider-pivotal dschneider-pivotal merged commit 5cbb203 into apache:develop Sep 13, 2021
@dschneider-pivotal dschneider-pivotal deleted the opimizePubSub branch September 13, 2021 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

redis Issues related to the geode-for-redis module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants