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

Remove useless e2ee decryptions on initial sync #4307

Closed
manuroe opened this issue May 6, 2021 · 0 comments · Fixed by matrix-org/matrix-ios-sdk#1096
Closed

Remove useless e2ee decryptions on initial sync #4307

manuroe opened this issue May 6, 2021 · 0 comments · Fixed by matrix-org/matrix-ios-sdk#1096

Comments

@manuroe
Copy link
Member

manuroe commented May 6, 2021

We need to decrypt encrypted messages to compute notifications and other things locally. But decryption uses CPU, about 5ms per decryption on an iPhoneX.

Currently, we decrypt all events received from an initial /sync. We can save some operations: this is useless to try to compute notifications on messages already read by the user.

An initial /sync on my account currently triggers 2179 decryptions, taking 12.4s (currently on the main thread). If I decrypt only messages that are newer than my read receipts, I decrypt 4 times less messages, 524, using 3.2 seconds of CPU.

So, the first step to improve this is to consider user read receipts before decrypting.
We probably need to decrypt messages that occurred a bit before to handle correctly call signalling in case the user switches devices. If the RR happened at t0, we should decrypt messages newer than t0 - 2min (incoming call life time is 1min, the RR can appear 59s after the incoming call event).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant