perf: avoid unnecessary clone and pre-allocate Vecs in hot paths - #545
Conversation
- send.rs: borrow own_sending_jid.user instead of cloning CompactString into the retain closure - usync.rs: collect device nodes to get count, then pre-allocate Vec instead of growing from empty - message.rs: pre-allocate enc_nodes Vec with capacity 4 in the message decrypt path (typical messages have 1-2 enc nodes)
|
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)
📝 WalkthroughWalkthroughThree micro-optimizations: preallocate vectors in message parsing and device parsing, and switch a local recipient user to borrowing in SKDM recipient filtering. No control-flow or public API changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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 50s —— View job Code Review:
|
Benchmark Results1 regression(s) detected (>2% threshold):
58 unchanged benchmark(s)
|
Avoids materializing the iterator into a temporary Vec just to get a count. Filter iterators propagate the parent's upper bound through size_hint(), which here is the total children count.
|
@claude do you have any idea why benchmark regreted? |
|
Claude finished @jlucaso1's task in 3m 55s —— View job Investigating benchmark regression
Why
|
size_hint() on Flatten+Filter returns (0, None) — the previous approach was a no-op equivalent to Vec::new(). Use the total children count as an upper-bound estimate instead.
Summary
own_sending_jid.userinstead of cloning theCompactStringinto the retain closuresize_hint()upper bound to pre-allocate device Vec instead of growing from emptyTest plan
Summary by CodeRabbit