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

Import progress for room keys with Crypto V2 #1637

Merged
merged 1 commit into from
Nov 15, 2022
Merged

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Nov 15, 2022

Split up room keys into batches of 1000 when importing, and ensure to decrypt + import within autoreleasepool. This ensures we do not run out of memory when importing large key backups.

Additionally expose importProgress property, analogous to existing backupProgress, that can be used by any UI.

Tested by importing 1,000,000 keys on a device, which does grow the memory footprint considerably, but still slower than without the autoreleasepool and batching. The initial spike seen below is the http request, roughly 800MB for all the keys.

Screenshot 2022-11-15 at 11 47 06

@Anderas Anderas requested review from a team and alfogrillo and removed request for a team November 15, 2022 11:30
@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Base: 16.02% // Head: 36.15% // Increases project coverage by +20.12% 🎉

Coverage data is based on head (e5dd8d3) compared to base (554db86).
Patch coverage: 61.76% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1637       +/-   ##
============================================
+ Coverage    16.02%   36.15%   +20.12%     
============================================
  Files          583      583               
  Lines        92528    92556       +28     
  Branches     39030    40240     +1210     
============================================
+ Hits         14830    33463    +18633     
+ Misses       77213    58088    -19125     
- Partials       485     1005      +520     
Impacted Files Coverage Δ
.../Crypto/KeyBackup/Engine/MXNativeKeyBackupEngine.m 64.52% <0.00%> (+64.52%) ⬆️
MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m 60.96% <0.00%> (+60.96%) ⬆️
...pto/KeyBackup/Engine/MXCryptoKeyBackupEngine.swift 47.33% <67.74%> (-0.52%) ⬇️
...o/Algorithms/RoomEvent/MXRoomEventDecryption.swift 57.07% <0.00%> (-0.59%) ⬇️
MatrixSDK/Threads/MXThreadNotificationsCount.swift 0.00% <0.00%> (ø)
MatrixSDK/Utils/Media/MXMediaManager.m 1.88% <0.00%> (+0.47%) ⬆️
MatrixSDK/Contrib/Swift/MXRestClient.swift 2.32% <0.00%> (+0.77%) ⬆️
...gations/LocationSharing/MXBeaconAggregations.swift 4.44% <0.00%> (+1.26%) ⬆️
MatrixSDKTests/MXBackgroundSyncServiceTests.swift 1.84% <0.00%> (+1.84%) ⬆️
MatrixSDK/Contrib/Swift/MXSession.swift 14.38% <0.00%> (+2.05%) ⬆️
... and 183 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@alfogrillo alfogrillo left a comment

Choose a reason for hiding this comment

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

IGTM!

@@ -362,6 +382,10 @@ class MXCryptoKeyBackupEngine: NSObject, MXKeyBackupEngine {
return try backup.exportRoomKeys(passphrase: passphrase)
}

func importProgress() -> Progress? {
return activeImportProgress
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return activeImportProgress
activeImportProgress

@Anderas Anderas merged commit 756c355 into develop Nov 15, 2022
@Anderas Anderas deleted the andy/large_backups branch November 15, 2022 14:10
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