Skip to content
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

Track timer state to optimize message publication (stable branch) #54

Merged

Conversation

richardlarocque
Copy link
Contributor

Tracks the state of the timer so we can tell the difference between the timer being expired and the timer not being set. This allows us to avoid settings lots of redundant timers when publishing messages while other messages are reaching their delivery time.

This is a successor to #53, which was targeting the master branch.

That PR was a successor to #51, which contained a different approach for solving the same problem. See that issue and https://groups.google.com/forum/#!topic/rabbitmq-users/XgjY7UtLkfs for more information.

Adds explicit tracking for the case where no timer is set.  In that
case, the timer is assigned to the `not_set` atom.  This allows us to
distinguish between the cases where no timer is set and the case where
the timer was set but has expired.

Previously, the `internal_delay_message` function was unable to tell the
difference between these two cases.  This is a problem because the
action it should take in either case is different.  If the timer was
never set, the enqueue code path must start one.  If the timer has
expired and will be processed soon, then starting a new timer would be a
waste of time.  The previous solution was to always start the timer,
since that does not affect correctness.

Now that we can distinguish the two scenarios, the enqueue path can
handle each case independently.  This makes enqueing significantly
faster in the case where enqueuing coincides with messages becoming
ready for delivery.
@richardlarocque
Copy link
Contributor Author

I don't understand the test failures. Let me know if there's something I can do to fix them.

@hairyhum hairyhum merged commit d2412f6 into rabbitmq:stable Jun 8, 2016
@hairyhum
Copy link
Contributor

hairyhum commented Jun 8, 2016

Thanks @richardlarocque

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.

3 participants