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

feat(sdk): Subscribe to many rooms only via Sliding Sync #3820

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Aug 8, 2024

This patch changes the SlidingSync::subscribe_to_room method to subscribe_to_rooms. Note the plural form. It's now mandatory to subscribe to a set of rooms. The idea is to avoid calling this method repeatedly. Why? Because each time the method is called, it sends a SlidingSyncInternalMessage of kind SyncLoopSkipOverCurrentIteration, i.e. it cancels the in-flight sliding sync request, to start over with a new one (with the new room subscription). A problem arises when the async runtime (here, Tokio) is busy: in this case, the internal message channel can be filled pretty easily because its size is 8. Messages are not consumed as fast as they are inserted. By changing this API: subscribing to multiple rooms will result in a single internal message, instead of one per room.

Consequently, the rest of the patch moves the subscribe method of room_list_service::Room to room_list_service::RoomListService because it now concerns multiple rooms instead of a single one.

@Hywan Hywan requested a review from a team as a code owner August 8, 2024 15:28
@Hywan Hywan requested review from jmartinesp and stefanceriu and removed request for a team August 8, 2024 15:28
This patch changes the `SlidingSync::subscribe_to_room` method to
`subscribe_to_rooms`. Note the plural form. It's now mandatory to
subscribe to a set of rooms. The idea is to avoid calling this method
repeatedly. Why? Because each time the method is called, it sends a
`SlidingSyncInternalMessage` of kind `SyncLoopSkipOverCurrentIteration`,
i.e. it cancels the in-flight sliding sync request, to start over with
a new one (with the new room subscription). A problem arises when the
async runtime (here, Tokio) is busy: in this case, the internal message
channel can be filled pretty easily because its size is 8. Messages
are not consumed as fast as they are inserted. By changing this API:
subscribing to multiple rooms will result in a single internal message,
instead of one per room.

Consequently, the rest of the patch moves the `subscribe` method of
`room_list_service::Room` to `room_list_service::RoomListService`
because it now concerns multiple rooms instead of a single one.
@Hywan Hywan force-pushed the feat-ui-room-list-subscribe-to-multiple-rooms branch from 6fa2571 to ad01e64 Compare August 8, 2024 15:40
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.09%. Comparing base (57963dc) to head (ad01e64).
Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3820      +/-   ##
==========================================
+ Coverage   84.07%   84.09%   +0.01%     
==========================================
  Files         263      263              
  Lines       27471    27473       +2     
==========================================
+ Hits        23097    23103       +6     
+ Misses       4374     4370       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

It's hard to confirm since Android didn't have an issue with the previous approach, but everything seems to work fine AFAICT, and we no longer have long lists of 'subscribing to...' logs, which is a plus since it reduces the noise quite a bit.

Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

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

looks and works great on iOS too, no more panics either 👍

@stefanceriu stefanceriu merged commit be404f6 into matrix-org:main Aug 9, 2024
40 checks passed
@Hywan Hywan mentioned this pull request Aug 14, 2024
33 tasks
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