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

Optimise notifier #17765

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Optimise notifier #17765

wants to merge 5 commits into from

Conversation

erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented Sep 27, 2024

The notifier is quite inefficient when it has to wake up many user streams all at once

From a silly benchmark this takes the time to notify 1M user streams from ~30s to ~5s

We can update the counter once outside of the loop.
Turns out doing `.copy_and_advance` can be expensive
@erikjohnston erikjohnston marked this pull request as ready for review September 27, 2024 09:01
@erikjohnston erikjohnston requested a review from a team as a code owner September 27, 2024 09:01

# The last token for which we should wake up any streams that have a
# token that comes before it. This gets updated every time we get poked.
# We start it at the current token since if we get any streams
# that have a token from before we have no idea whether they should be
# woken up or not, so lets just wake them up.
self.last_notified_token = current_token
self.current_token = current_token
Copy link
Member Author

Choose a reason for hiding this comment

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

These two variables were always the same, so may as well remove one of them

sync_channel.await_result()
self.assertEqual(200, sync_channel.code)
next_batch = sync_channel.json_body["next_batch"]

Copy link
Member Author

Choose a reason for hiding this comment

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

This is because we now replace the current token rather than copy_and_advance. The test is still asserting the same observable behaviour really.

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.

1 participant