Skip to content

Bindings optimisation #1715

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

Merged
merged 2 commits into from
Oct 2, 2018
Merged

Bindings optimisation #1715

merged 2 commits into from
Oct 2, 2018

Conversation

hairyhum
Copy link
Contributor

@hairyhum hairyhum commented Sep 28, 2018

A follow-up to #1589.
Fixes #1690.

A number of optimisations around bindings. Apparently there is not much sense in adding table indexes to binding tables, as index read locks entire table. Indexes could slightly improve performance when there are many bindings and queues, but will require a breaking change in the schema.

The changes in this branch provide performance improvement comparable to introduction of indexes without reworking the schema:

  • Replaced delete_object with delete as bindings are value-objects and there are no bag tables
  • In some lookups during cleanup match_object is replaced with dirty_match_object to not lock the entire bindings table. This change was reverted in d0423f9 because it was creating inconsistencies with dirty_delete. Current branch does not contain dirty deletes. Still requires more testing.
  • Default bindings are removed. The default exchange does direct lookup of queues without actually loading the bindings and default bindings are not unbindable and only displayed in list_bindings. They are not used, but slow down queue deletion and creation.

Benchmark data will follow.

…in bindings where possible.

Route table key contains all the route information, which makes delete
equivalent to delete_object. But it's faster.

For the same reason match_object with a full object is equivalent to read.
match_object locks entire table, we'd like to avoid that.

It's possible to not call delete_for_source if exchange is autodeleted.
Checking an autodelete exchange will lock table on scanning for outgoing
bindings anyway. But other cases will not lock the table.
@hairyhum
Copy link
Contributor Author

hairyhum commented Sep 28, 2018

Exclusive queue cleanup benchmark:

Time to cleanup queues on connection:

100K queues No explicit bindings 1 binding 2 bindings
Before 57.7 sec 77.9 sec 107.1 sec
After 20.9 sec 25.7 sec 30.5 sec

Since default bindings are a separate PR now, this numbers should be shifted right for the "after" row. Still there is an optimisation.

@hairyhum
Copy link
Contributor Author

Time to delete queues/exchanges:

10K exchanges 1 queue 10K queues 1 exchange 1 exchange 1 queue 10000 bindings 1 queue 1000 exchanges 10 bindings
Before 3.7 sec 3.8 sec 4.1 sec 3.6 sec
After 0.979 sec 0.891 sec 0.765 sec 0.79 sec

@hairyhum
Copy link
Contributor Author

This can be backported to 3.7 if accepted.

Copy link
Collaborator

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

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

I observe test failures not present in master, e.g. try

gmake distclean; gmake ct-queue_master_location; open logs/index.html

@hairyhum
Copy link
Contributor Author

hairyhum commented Oct 1, 2018

The interesting thing about default bindings and min-master locator is that it's counting queue masters looking at bindings, but all queues were bound. Originally it was counting bindings and selecting a node which min bindings to the queues on the node. Then it was changed in 1d413ea to count multiple bindings for the same queue as one. The assumption was that we should not account for unbound queues. But any queue had at least 1 binding (default).
I'm going to make it count queues, because it will be the same behaviour.

@hairyhum
Copy link
Contributor Author

hairyhum commented Oct 1, 2018

The test now passes.

Copy link
Collaborator

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

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

The above failures are gone but there are still failures in rabbitmq-management's test suite that are not present in master, e.g. try:

gmake ct-rabbit_mgmt_http

Not all tests have something to do with bindings.

@hairyhum
Copy link
Contributor Author

hairyhum commented Oct 2, 2018

So default bindings are shown in the management API. I've missed that somehow. I still don't think we should store them in the database. Maybe we could fake them for the management API
I'm going to create a separate PR with default bindings removed.

@hairyhum
Copy link
Contributor Author

hairyhum commented Oct 2, 2018

Moved default bindings removal to a separate PR since most of the failures are about that change. It might be even for 3.8.

@michaelklishin
Copy link
Collaborator

@hairyhum we can append them in HTTP API handlers and rabbitmqctl list_bindings in CLI.

@michaelklishin
Copy link
Collaborator

…or functions that list bindings, that'd cover more cases with a single change?

@hairyhum
Copy link
Contributor Author

hairyhum commented Oct 2, 2018

@michaelklishin maybe. That's why it's a separate PR.

@michaelklishin
Copy link
Collaborator

This branch passes the test from #1691. LGTM.

@michaelklishin michaelklishin merged commit da4a6c0 into master Oct 2, 2018
@michaelklishin michaelklishin deleted the bindings-optimisation branch October 2, 2018 23:25
hairyhum added a commit that referenced this pull request Oct 3, 2018
@hairyhum
Copy link
Contributor Author

hairyhum commented Oct 3, 2018

Merged to 3.7

@michaelklishin
Copy link
Collaborator

#1721, a spin-off from this issue, was merged for 3.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants