-
Notifications
You must be signed in to change notification settings - Fork 38
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
Initial sync uses a ton of memory on Synapse's synchrotron #258
Comments
final tally for memory usage was 11gb. |
Sounds like a Synapse bug to me. Lines 97 to 132 in 3bf3f23
We use a filter for two purposes:
|
I can't see any difference in the filtering logic for these two cases: https://github.com/matrix-org/synapse/blob/54317d34b76adb1e8f694acd91f631b3abe38947/synapse/rest/client/sync.py#L166-L187 |
from the sliding sync internal room, a realization: the filter sliding sync uses does not lazy load room members, while Element Desktop will. This almost certainly explains the 11gb of memory required to process the initial sync. If it's not strictly required to have all the member events, I'd suggest the proxy aggressively lazy load members. |
The proxy needs the member events at every event in order to locally calculate history visibility. E.g consider:
The proxy was not designed to handle partial room state, and adding that in would be a significant, risky and costly change. |
The scenario above is mitigated somewhat because of the cache invalidation work, coupled with #366 - the proxy tries really hard NOT to do history visibility checks so it will cut off serving events up to the user's join event. There's still numerous pitfalls:
We ultimately need the entire member list. Synapse ideally should stream the list back if it's too large. |
To further emphasise why we cannot using Synapse lazy loading: it's not even accurate. See element-hq/synapse#17050 and related issues. |
I set up a brand new sliding sync proxy to test Element Android X, and when it actually started the poller for the first time it slowly ate all 7.5gb of memory I was able to give the synapse synchrotron worker, eventually causing OOM issues.
For comparison, an initial sync for my account on Element Desktop only uses 2-3gb of Synapse's synchrotron.
I suspect this is related to the use of an inline filter on the initial sync, but haven't confirmed. Using a pre-uploaded filter might yield better results, as I believe Synapse does the filtering in-database when using a pre-uploaded filter.
The text was updated successfully, but these errors were encountered: