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

Batch migrate olm and megolm sessions #1687

Merged
merged 3 commits into from
Jan 23, 2023
Merged

Batch migrate olm and megolm sessions #1687

merged 3 commits into from
Jan 23, 2023

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Jan 18, 2023

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

@Anderas Anderas requested review from a team and Velin92 and removed request for a team January 18, 2023 16:20
@Anderas Anderas force-pushed the andy/large_accounts branch 3 times, most recently from b3255d4 to f42240e Compare January 18, 2023 16:42
Base automatically changed from andy/startup_stage to andy/migrate_crypto January 23, 2023 09:21
Base automatically changed from andy/migrate_crypto to develop January 23, 2023 09:21
log.debug("Migrating olm sessions in batches")

// How much does migration of olm vs megolm sessions contribute to the overall progress
let olmToMegolmProgressRatio = 0.25
Copy link
Member

@Velin92 Velin92 Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this on element but yeah this could be a computed value of olm / (olm + megolm)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix applied here

@Anderas Anderas merged commit d969cf4 into develop Jan 23, 2023
@Anderas Anderas deleted the andy/large_accounts branch January 23, 2023 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants