perf(signal): flush the signal cache without holding the device read-lock - #888
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesSignal Cache Flush Lock Scope Reduction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
📦 Binary size report
.text per crate
Top movers (cargo-bloat attribution)
Baseline: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 496da5a220
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
What
flush_signal_cachetook theDeviceread()guard and held it across the entiresignal_cache.flush(...)call. The guard was only used to borrowdevice.backend(anArc<dyn Backend>), so this clones the backendArcout of the device snapshot and drops the guard before flushing — the batched SQLite write now runs holding no device lock.Why
signal_cache.flushis a batched SQLite write, andflush_signal_cacheruns once per decrypted message and on most sends. Holding the device read-guard for the whole flush blocked every concurrentmodify_device/process_command(a Device write) for the flush duration, creating read↔write lock contention on the per-message hot path. The backend handle is cheap to clone, so nothing needs the guard held during the I/O.No behavior change: same backend, same flush, only the lock is no longer held across it. This mirrors the existing pattern in
prekeys.rs(get_device_snapshot().backend.clone()).Tests
cargo clippy --all --testsclean;cargo test -p whatsapp-rustpasses (862).