-
Notifications
You must be signed in to change notification settings - Fork 358
fix(ui): Change how SlidingSync enables long-polling
#5878
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
Conversation
CodSpeed Performance ReportMerging #5878 will not alter performanceComparing Summary
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5878 +/- ##
==========================================
- Coverage 88.60% 88.59% -0.01%
==========================================
Files 363 363
Lines 102926 102943 +17
Branches 102926 102943 +17
==========================================
+ Hits 91194 91207 +13
- Misses 7490 7493 +3
- Partials 4242 4243 +1 ☔ View full report in Codecov by Sentry. |
stefanceriu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👏 Hope this is the last time we'll have to tweak it.
| match observable_state.get() { | ||
| // These are the states where we want an immediate response from the | ||
| // server, with no long-polling. | ||
| State::Init | ||
| | State::SettingUp | ||
| | State::Recovering | ||
| | State::Error { .. } | ||
| | State::Terminated { .. } => false, | ||
|
|
||
| // Otherwise we want long-polling if the list is fully-loaded. | ||
| State::Running => request_generator.is_fully_loaded(), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ended up being so nice and clean 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
This patch updates `SlidingSyncListInner::state` from a `RwLock<Observable>` to a `SharedObservable`. It is semantically and programmatically identical, but the API is simpler.
…_mode`. This patch updates the documentation of `SlidingSyncList::set_sync_mode` to remove an outdated reference to a `reset` method that no longer exists.
This patch adds a new `SlidingSyncListBuilder::requires_timeout` method that takes a function deciding whether the list requires a timeout, i.e. if the list should trigger a `http::Request::timeout`, i.e. if it deserves a long-polling or not. The default behaviour is kept for compatibility purposes.
…vice`. This patch uses the newly introduced `SlidingSyncListBuilder::requires_timeout` to define when the `RoomListService` must apply a long-polling depending on its state machine.
This patch declares the type of the expected value for `assert pos`.
This patch tests whether long-polling is used for Sliding Sync requests made by `RoomListService`.
This patch changes how
SlidingSyncenables long-polling. Long-polling with sliding sync is based on atimeoutquery parameter. If absent or 0, the server is expected to return immediately, otherwise the server waits up to timeout milliseconds before returning a response.Before this patch, to define whether long-polling was necessary, we were relying on this simple algorithm (applied onto each sliding sync list):
Selective(i.e. it has a constant range), or if the list is fully loaded, then do long-polling,This behaviour has been introduced in #3853.
As pointed in #5862, this algorithm is a bit annoying with our today's use of
SlidingSync. Why? Because sometimes the server has nothing new to return despite the list is notSelectiveand is not fully-loaded. Thus, we need a more customizable mechanism, hence this set of patches.First off, we introduce a new
SlidingSyncListBuilder::requires_timeoutmethod that accepts a user-defined function controlling whether a timeout is required or not, i.e. if the sliding sync client must do long-polling or not. The default function mimics the existing behaviour for compatibility purposes.Second,
RoomListServicedefines its own function, and uses it.Finally, the test suite has been updated to test this new behaviour.