matrix-org / matrix-org/matrix-rust-sdk

`process_sync_changes` always updates `account` in the store

Open
#2,448 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

Every time `process_sync_changes` is called, it persists the current state of the Account to the store (https://github.com/matrix-org/matrix-rust-sdk/blob/8deb0ff2e18c33d3588eef78e6040fe8a4d4cf41/crates/matrix-sdk-crypto/src/machine.rs#L1171-L1174).

IndexedDB storage operations can be quite slow, and since `process_sync_changes` is called for every sync (indeed, three times for every sync on Web), this is quite expensive and can be rather slow.

I don't really follow why we need to store the account at this point (why not when we create the session?), but could we give it a 'dirty' bit to indicate whether it needs updating, rather than doing it unconditionally?

Contributor guide

Open the contributing guide

Research direction

Start in crates/matrix-sdk-crypto/src/machine.rs at process_sync_changes and inspect the account persistence around lines 1171-1174. Trace when the Account changes and how IndexedDB storage is used on Web; done means unchanged accounts are not persisted on every sync while necessary updates still reach the store.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.