Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Improve performance of /sync when the filter specifies no room IDs #14784

Closed
kegsay opened this issue Jan 6, 2023 · 2 comments · Fixed by #14786 or #14908
Closed

Improve performance of /sync when the filter specifies no room IDs #14784

kegsay opened this issue Jan 6, 2023 · 2 comments · Fixed by #14786 or #14908
Labels
A-Sync defects related to /sync O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Minor Blocks non-critical functionality, workarounds exist. T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.

Comments

@kegsay
Copy link
Member

kegsay commented Jan 6, 2023

Description

Related: #10842

It would be nice It is critical for Sliding Sync if Synapse checked if the filter JSON was specifying a set of room IDs, and if so just apply /sync to those rooms, which should be significantly faster than a general /sync.

Context: Sliding Sync hits /sync on behalf of users. The first sync is always slow because it needs the data from /sync. However, the first /sync on a 2nd+ device for the same user can be very fast, because the proxy does not wait for the /sync response, it can just serve up the room data fetched from the 1st device. However, to-device messages are per-device and only arrive with the /sync response: I can't do the same trick. In an effort to reduce the /sync time, I specify a filter with room.rooms=[] which means "no room IDs". This correctly returns no rooms, but it still takes just as long to process.

The end-user impact here is that, whilst Matthew can login to sliding-sync enabled Elements within seconds, it takes 15+ minutes before he can read E2EE messages because to-device messages are delayed.

Steps to reproduce

  • Matthew hits /sync with a filter of { room: { rooms: [] } }
  • Watch it churn for 15mins before returning.

Homeserver

matrix.org

Synapse Version

1.74.0

Installation Method

Other (please mention below)

Database

N/A

Workers

Multiple workers

Platform

N/A

Configuration

N/A

Relevant log output

N/A

Anything else that would be useful to know?

No response

@clokep
Copy link
Member

clokep commented Jan 6, 2023

@kegsay I don't think filtering with an empty array does anything, see matrix-org/matrix-spec#1312. You could try a filter of { room: { not_rooms: ["*"] } } which I think will be slightly better, but will still do some processing over rooms.

@clokep clokep changed the title Improve performance of /sync when the filter specifies room IDs Improve performance of /sync when the filter specifies no room IDs Jan 6, 2023
@clokep clokep self-assigned this Jan 6, 2023
@clokep
Copy link
Member

clokep commented Jan 10, 2023

#14786 did help here, but...skipped properly calculating changed devices. I'm going to re-open this and back-out the broken bits (#14810).

@clokep clokep reopened this Jan 10, 2023
@clokep clokep removed their assignment Jan 11, 2023
@clokep clokep added A-Sync defects related to /sync S-Minor Blocks non-critical functionality, workarounds exist. T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Jan 11, 2023
@clokep clokep linked a pull request Feb 2, 2023 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Sync defects related to /sync O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Minor Blocks non-critical functionality, workarounds exist. T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.
Projects
None yet
2 participants