Skip to content

Bugfix/fix linear time search for registrations 5.0#159

Merged
zyclonite merged 4 commits intovert-x3:5.0from
mutexd:bugfix/fix-linear-time-search-for-registrations-5.0
Apr 8, 2026
Merged

Bugfix/fix linear time search for registrations 5.0#159
zyclonite merged 4 commits intovert-x3:5.0from
mutexd:bugfix/fix-linear-time-search-for-registrations-5.0

Conversation

@mutexd
Copy link
Copy Markdown
Contributor

@mutexd mutexd commented Apr 2, 2026

Motivation:

I'm switching between different cluster-managers in Vertx and I found out that in one situation, IgniteClusterManager performs way slower than HazelClusterManager. I have one Verticle frequently publishing to addresses that have not been subscribed by any consumer yet. Vertx continues to invoke clusterManager->getRegistrations(), and SubsMapHelper->get() takes up lots of cpu time. Having a look at the implementation between HazelClusterManager and IgniteClusterManager suggests that the IgniteClusterManager->SubsMapHelper->get() has performance issue when the number of registrations are large.

Solution:

The original implementation flatten all the registrations into the keys of the Map. When we need to search for all registrations of an address, it uses query() and the complexity essentially grows with the number of registrations linearly.
Instead, we should make use of the constant time assess in Map that we store address as the key so that when we search for all registrations, we directly get the result and we don't have to do linear time search among all registrations.

Comparison:
IgniteClusterManager.getRegistrations

test cpu time % of total
before 230164 67.54%
after 1729 2.43 %

Before:
Screenshot from 2026-03-27 08-31-23
After:

Screenshot from 2026-03-27 08-32-13

Note:
Author @zyclonite provides the solution for keeping the atomicity.

mutexd added 4 commits April 2, 2026 16:02
- The original implementation flatten all the registrations into the keys
  of the Map. When we need to search for all registrations of an
  address, it uses query() and the complexity essentially grows with the
  number of registrations linearly.
- Instead, we should make use of the constant time asscess in Map that we store address as the key so
  that when we search for all registrations, we directly get the result
  and we don't have to do linear time search among all registrations.
@zyclonite zyclonite added the bug label Apr 7, 2026
@zyclonite zyclonite added this to the 5.0.11 milestone Apr 7, 2026
@zyclonite zyclonite self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Member

@zyclonite zyclonite left a comment

Choose a reason for hiding this comment

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

lgtm

@zyclonite zyclonite merged commit 6c028b4 into vert-x3:5.0 Apr 8, 2026
3 of 4 checks passed
zyclonite added a commit to zyclonite/vertx-ignite that referenced this pull request Apr 9, 2026
zyclonite added a commit that referenced this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants