element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
Apache License 2.0
10.99k stars 1.95k forks source link

Element-R: "Migrate to rust" labs button #26678

Closed richvdh closed 7 months ago

richvdh commented 9 months ago

At some point we will need to start actively migrating people who are using EW sessions on legacy Crypto to Rust crypto.

We will need a migration process for this. To gain confidence in the migration, we will add some sort of "developer feature" where people can request a migration. Later, we will automate the migration.

### Tasks
- [ ] https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/issues/78
- [ ] https://github.com/matrix-org/matrix-js-sdk/issues/3963
- [ ] https://github.com/matrix-org/matrix-js-sdk/issues/3964
- [ ] https://github.com/element-hq/element-web/issues/26772
- [ ] https://github.com/element-hq/element-web/issues/26773
- [ ] https://github.com/element-hq/element-web/issues/26894
- [ ] https://github.com/element-hq/element-web/issues/26820
richvdh commented 9 months ago

UX for this will be a labs button that causes the session to be restarted when it is enabled.

We probably need some sort of modal that indicates the state of the migration.

richvdh commented 8 months ago

Some thoughts on how to achieve this:

We are ignoring:

Stuff we may need to figure out how to import later:

richvdh commented 8 months ago

Looking at the performance of this as it stands:

On a test database containing 37 olm sessions and 4810 megolm sessions:

Obviously, that is dominated by the megolm session import, at 12.5s for 4810 sessions, or ~130ms for each batch of 50 sessions. The actual time for each batch is quite variable, but there are three stages:

Somewhat unexpected that deleting things from the old db is what takes the time. We could reduce it to (empirically) about 54.9ms by iterating through the store looking for rows to delete instead of using the index (which works because we know the batch will be at the "start" of the store); or we could rewrite the whole thing to store the progress made so far and delete everything on a single batch at the end. Not sure it is worthwhile though. If we need it to go faster, we can do it in the background.