Skip to content

Less coarse-grained locking for bindings add/remove operations #1900

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 1 commit into from
Feb 28, 2019

Conversation

hairyhum
Copy link
Contributor

@hairyhum hairyhum commented Feb 26, 2019

Proposed Changes

All binding operations aquire special locks for destination and source.
This is done to make sure bindings cannot be added or removed while
being cleaned up.

This means that adding and removing bindings for the same records may
conflict.

To avoid conflict the locks aquired during add/remove are now read locks.

This should improve performance in case of concurrent bindings creation
for the same resource.

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Optimisation
  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

This change needs some functional performance testing. It's suppose to improve the situation when multiple connections try to bind their queues (e.g. exclusive queues) to the same exchange concurrently.

All binding operations aquire special locks for destination and source.
This is done to make sure bindings cannot be added or removed while
being cleaned up.

This means that adding and removing bindings for the same records may
conflict.

To avoid conflict the locks aquired during add/remove are now read locks.

This should improve performance in case of concurrent bindings creation
for the same resource.
@hairyhum
Copy link
Contributor Author

hairyhum commented Feb 26, 2019

Test: binding a queue to exchange 10 times in each process with different routing keys.

Tested on the node, calling rabbit_binding:add for the same source and
destination with different keys.

Time in microseconds, collected by timer:tc

Without the change With the change
100 processes 1000 bindings ~420 ms ~350 ms
500 processes 5000 bindings ~1450 ms ~650 ms
1000 processes 10000 bindings ~2780 ms ~1080 ms

@michaelklishin michaelklishin changed the title Less aggressive locking for bindings add/reomve. Less coarse-grained locking for bindings add/remove operations Feb 26, 2019
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.

This looks good but during our sync-up we learned that it is not yet ready for QA.

@michaelklishin michaelklishin changed the title Less coarse-grained locking for bindings add/remove operations DRAFT Less coarse-grained locking for bindings add/remove operations Feb 27, 2019
@hairyhum
Copy link
Contributor Author

More testing:

Without the change With the change
1 node
Durable
10 processes 100 bindings ~260 ms ~210 ms
100 processes 1000 bindings ~400 ms ~380 ms
1000 processes 10000 bindings ~2100 ms ~1380 ms
Transient
10 processes 100 bindings ~30 ms ~10 ms
100 processes 1000 bindings ~250 ms ~75 ms
1000 processes 10000 bindings ~2000 ms ~700 ms
2 nodes
Durable
10 processes 100 bindings ~320 ms ~230 ms
100 processes 1000 bindings ~1230 ms ~460 ms
1000 processes 10000 bindings ~11700 ms ~3310 ms
Transient
10 processes 100 bindings ~100 ms ~23 ms
100 processes 1000 bindings ~860 ms ~200 ms
1000 processes 10000 bindings ~8300 ms ~2100 ms

As expected, with more nodes the difference is more visible.
I'm getting convinced that the change is good enough performance-wise.

@hairyhum hairyhum marked this pull request as ready for review February 28, 2019 17:53
@hairyhum hairyhum changed the title DRAFT Less coarse-grained locking for bindings add/remove operations Less coarse-grained locking for bindings add/remove operations Feb 28, 2019
@hairyhum hairyhum added this to the 3.7.x milestone Feb 28, 2019
@michaelklishin michaelklishin merged commit 339b5bf into master Feb 28, 2019
@michaelklishin michaelklishin deleted the binding-lock-optimisation branch February 28, 2019 18:20
@michaelklishin
Copy link
Collaborator

Let's wait for a bit and perhaps backport after 3.7.13 GA ships next week.

@michaelklishin
Copy link
Collaborator

Good job, @hairyhum 👍👍

@michaelklishin
Copy link
Collaborator

References #1513, #1690, #1589, #1715.

@michaelklishin michaelklishin modified the milestones: 3.7.x, 3.7.13, 3.7.14 Feb 28, 2019
@michaelklishin
Copy link
Collaborator

3.7.x feels most appropriate before we backport.

@michaelklishin michaelklishin modified the milestones: 3.7.x, 3.7.14 Mar 13, 2019
@michaelklishin
Copy link
Collaborator

Backported to v3.7.x.

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