perf!: immutable load_sender_key and auto-reserve marshal - #503
Conversation
SenderKeyStore::load_sender_key(&mut self) -> load_sender_key(&self): - No implementation mutates self during load (all 4 impls verified) - Unlocks concurrent group decryption — multiple senders can be decrypted in parallel without serializing on &mut - group_encrypt/group_decrypt keep &mut for store_sender_key (writes) marshal_auto_to_vec: - New public function combining auto-reserve capacity estimation with the fast VecByteWriter path - send_node() now uses marshal_auto_to_vec instead of marshal_to (generic Write trait), avoiding buffer reallocations for large group stanzas (~50KB for 256-member SKDM distribution) - Benchmarked: -0.33% instructions, -2.13% RAM hits on SKDM 256
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR makes the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@claude review |
|
Claude finished @jlucaso1's task in 1m 22s —— View job Code Review:
|
|
| Branch | perf/sender-key-read-and-marshal-auto |
| Testbed | ubuntu-latest |
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
Summary
BREAKING:
SenderKeyStore::load_sender_key(&self)Changes the trait method from
&mut selfto&self. All 4 implementations verified — none mutate during load:Device::load_sender_key— only callsbackend.get_sender_key()(read)SenderKeyAdapter::load_sender_key— acquires read lock + cache readMemSenderKeyStore(bench) —HashMap::get()onlyInMemorySenderKeyStore(bench) —HashMap::get()onlyTest callers that held write locks just for
load_sender_keyare downgraded to read locks.group_encrypt,group_decrypt, andprocess_sender_key_distribution_messagekeep&mut dyn SenderKeyStorebecause they callstore_sender_key(write).Concurrency unlock: Code that only reads sender keys can now hold shared
&selfreferences, enabling concurrent reads at the application level.marshal_auto_to_vecNew public function in
wacore-binarythat combines auto-reserve capacity estimation with the fastVecByteWriterpath.send_node()now uses this instead ofmarshal_to(genericWritetrait).Benchmarked (SKDM 256): -0.33% instructions, -2.13% RAM hits — eliminates buffer reallocations for large group stanzas (~50KB).
Test plan
cargo fmt --allcargo clippy --all --tests— zero warningscargo test --workspace --exclude e2e-tests— all 28 suites passSummary by CodeRabbit