Skip to content

Compute the vault KDF's four lanes in parallel (unlock 194 ms → 56 ms) - #185

Open
Sadykhzadeh wants to merge 1 commit into
mainfrom
perf/parallel-argon2
Open

Sadykhzadeh wants to merge 1 commit into
mainfrom
perf/parallel-argon2

Conversation

@Sadykhzadeh

@Sadykhzadeh Sadykhzadeh commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Why

The vault key comes from Argon2id with 64 MiB, t=3, p=4. The workspace built argon2 without its parallel feature, so the four lanes ran one after another on one thread. Every unlock (passphrase, Touch ID passphrase check, reset verification, vault creation) paid for all four in wall time on any machine.

What changes

argon2 = { version = "0.6", features = ["parallel"] }. Lanes are computed on rayon's pool. Parameters, output and the cost to an attacker don't change; only the wait does.

New crates in the lock file: rayon 1.12.0, rayon-core 1.13.0, crossbeam-deque 0.8.8, crossbeam-epoch 0.9.21, either 1.19.0. cargo audit reports none of them.

Measured

Release build on this 4-core box, best of 5, same passphrase and salt:

KDF time First 4 output bytes
before 194 ms ef b5 1f 9a
after 56 ms ef b5 1f 9a

The vault's existing known-answer tests also pass unchanged. That's the check that matters: a different output would lock everyone out of their vault.

Test plan


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Argon2 was built without its parallel feature, so unlock ran all four
lanes one after another on a single thread.
@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

TREX TREX could not finish testing

  • Plan what to test
  • Set up the environment and test the changed flows
  • Post test results

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Parallelize the vault's four Argon2 KDF lanes

✨ Enhancement ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Enable Argon2's parallel feature to reduce vault key derivation wait time on multicore machines.
• Add the required Rayon dependencies without changing KDF parameters or derived keys.
Diagram

graph TD
  O["Vault operations"] --> V["Core vault KDF"] --> A["Argon2 parallel"] --> K["Vault key"]
  C["Cargo.toml feature"] --> A --> R["Rayon worker pool"]
  L["Cargo.lock dependencies"] --> R
Loading
High-Level Assessment

Use Argon2's existing parallel feature. It accelerates the four configured lanes without replacing the KDF or changing its output; a custom threading implementation would add unnecessary complexity and compatibility risk.

Files changed (2) +51 / -1

Enhancement (1) +5 / -1
Cargo.tomlEnable parallel Argon2 lane computation +5/-1

Enable parallel Argon2 lane computation

• Enables Argon2's 'parallel' feature in the workspace dependency and documents why the vault's four-lane KDF benefits. The KDF parameters remain unchanged.

Cargo.toml

Other (1) +46 / -0
Cargo.lockLock Argon2's parallel runtime dependencies +46/-0

Lock Argon2's parallel runtime dependencies

• Adds Rayon to Argon2's dependency list and locks Rayon, Rayon Core, Crossbeam Deque, Crossbeam Epoch, and Either.

Cargo.lock

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Qodo Logo

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.

1 participant