[PR #2685] [CLOSED] [PM-3426] Make cipher decryption faster by running in parallel #40826

Closed
opened 2026-04-23 19:38:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2685
Author: @quexten
Created: 8/13/2023
Status: Closed

Base: mainHead: parallel-cipher-decryption


📝 Commits (5)

  • 4104b86 Make cipher decryption parallel
  • 513367e Reintroduce try-catch in cipherservice
  • f0a7ea4 Undo formatting change
  • 0c8c1e4 Make parallel cipher decryption async
  • 43e8a12 Fix parallel cipher decrypt

📊 Changes

1 file changed (+18 additions, -23 deletions)

View changed files

📝 src/Core/Services/CipherService.cs (+18 -23)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

With a lot of ciphers in the vault, opening the vault (unlock/login) takes quite long (~25 seconds for my 10k cipher test vault). One of the causes seems to be that the cipher decryption runs concurrently (through async await) but not in parallel.

This PR rewrites the cipher decryption logic a bit to be both more readable and to run in parallel. On my emulator device, this brought the decryption time down to ~15 seconds. (An improvement, but there might still be a bottleneck somewhere else, since not all CPU resources were fully utilized. On the other hand, the emulator might also hinder further parallelization).

Related:
https://github.com/bitwarden/mobile/issues/579

Code changes

Screenshots

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/2685 **Author:** [@quexten](https://github.com/quexten) **Created:** 8/13/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `parallel-cipher-decryption` --- ### 📝 Commits (5) - [`4104b86`](https://github.com/bitwarden/android/commit/4104b866db2d608d916785e6edc44ea88d9ac002) Make cipher decryption parallel - [`513367e`](https://github.com/bitwarden/android/commit/513367ef83ff92887edc7978e9b450a5f2284138) Reintroduce try-catch in cipherservice - [`f0a7ea4`](https://github.com/bitwarden/android/commit/f0a7ea454fedd79d544a35775fa3e0ef01257309) Undo formatting change - [`0c8c1e4`](https://github.com/bitwarden/android/commit/0c8c1e4da3381794a57cfc2894e78834362c892b) Make parallel cipher decryption async - [`43e8a12`](https://github.com/bitwarden/android/commit/43e8a12df6cda26cc18f12a694f9ee7a131c05e3) Fix parallel cipher decrypt ### 📊 Changes **1 file changed** (+18 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `src/Core/Services/CipherService.cs` (+18 -23) </details> ### 📄 Description ## Type of change - [ ] Bug fix - [x] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective With a lot of ciphers in the vault, opening the vault (unlock/login) takes quite long (~25 seconds for my 10k cipher test vault). One of the causes seems to be that the cipher decryption runs concurrently (through async await) but not in parallel. This PR rewrites the cipher decryption logic a bit to be both more readable and to run in parallel. On my emulator device, this brought the decryption time down to ~15 seconds. (An improvement, but there might still be a bottleneck somewhere else, since not all CPU resources were fully utilized. On the other hand, the emulator might also hinder further parallelization). Related: https://github.com/bitwarden/mobile/issues/579 ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> - [CipherService.cs](https://github.com/bitwarden/mobile/compare/master...quexten:parallel-cipher-decryption?expand=1#diff-f8d20ac6245e78d9222fc49984a156e9a4e30278deb159d55744ee0962dfe220) use linq `.AsParallel()` to run the decryption in parallel ## Screenshots <!--Required for any UI changes. Delete if not applicable--> ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 19:38:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#40826