Batch migrate olm and megolm sessions #1687
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When migrating large accounts from libolm to rust (100K + room keys) the application consumes a lot of memory, first by fetching data from realm (all at once), then converting to rust objects, and then migrating to rust crypto store. For these large accounts we may even run out of memory before the migration completes.
To solve this add new methods to crypto store that can enumerate batches of sessions (with configurable batch size) that are wrapped in
autoreleasepool
. During migration we continuously enumerate olm and megolm sessions, and no matter how many there are, we can keep a mostly constant memory footprint.Due to the number of work necessary, migration now becomes an asynchronous task that needs to report its own progress. This is eventually tied into existing MXSessionStartupProgress and displayed on the loading page