-
-
Notifications
You must be signed in to change notification settings - Fork 127
perf: 11 allocation trims from hot-path audit #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1098,17 +1098,18 @@ impl Client { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| let mut adapter = self.signal_adapter().await; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Always use bare sender for sender key operations. Real WA delivers | ||||||||||||||||||||||||||||
| // skmsg with bare participant but pkmsg (SKDM) with device-qualified | ||||||||||||||||||||||||||||
| // participant — normalizing to bare ensures consistent lookup. | ||||||||||||||||||||||||||||
| // Hoisted out of the payload loop: all three are loop-invariant. | ||||||||||||||||||||||||||||
| let sender_for_sk = info.source.sender.to_non_ad(); | ||||||||||||||||||||||||||||
| let sender_address = sender_for_sk.to_protocol_address(); | ||||||||||||||||||||||||||||
| let sender_key_name = make_sender_key_name(&info.source.chat, &sender_address); | ||||||||||||||||||||||||||||
|
Comment on lines
+1101
to
+1107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stop stripping device scope from sender-key addresses here. This path normalizes Suggested fix- let sender_for_sk = info.source.sender.to_non_ad();
- let sender_address = sender_for_sk.to_protocol_address();
+ let sender_address = info.source.sender.to_protocol_address();
let sender_key_name = make_sender_key_name(&info.source.chat, &sender_address);Based on learnings: sender-key naming in this codebase should use device-scoped LID protocol addresses ( 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| for payload in payloads { | ||||||||||||||||||||||||||||
| let ciphertext = &payload.ciphertext[..]; | ||||||||||||||||||||||||||||
| let padding_version = payload.padding_version; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Always use bare sender for sender key operations. Real WA delivers | ||||||||||||||||||||||||||||
| // skmsg with bare participant but pkmsg (SKDM) with device-qualified | ||||||||||||||||||||||||||||
| // participant — normalizing to bare ensures consistent lookup. | ||||||||||||||||||||||||||||
| let sender_for_sk = info.source.sender.to_non_ad(); | ||||||||||||||||||||||||||||
| let sender_address = sender_for_sk.to_protocol_address(); | ||||||||||||||||||||||||||||
| let sender_key_name = make_sender_key_name(&info.source.chat, &sender_address); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| log::debug!( | ||||||||||||||||||||||||||||
| "Looking up sender key for group {} with sender address {} (from sender JID: {})", | ||||||||||||||||||||||||||||
| info.source.chat, | ||||||||||||||||||||||||||||
|
|
@@ -1434,10 +1435,14 @@ impl Client { | |||||||||||||||||||||||||||
| &self, | ||||||||||||||||||||||||||||
| node: &wacore_binary::NodeRef<'_>, | ||||||||||||||||||||||||||||
| ) -> Result<MessageInfo, anyhow::Error> { | ||||||||||||||||||||||||||||
| let device_snapshot = self.persistence_manager.get_device_snapshot().await; | ||||||||||||||||||||||||||||
| let (own_pn, own_lid) = { | ||||||||||||||||||||||||||||
| let arc = self.persistence_manager.get_device_arc().await; | ||||||||||||||||||||||||||||
| let guard = arc.read().await; | ||||||||||||||||||||||||||||
| (guard.pn.clone(), guard.lid.clone()) | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| let default_jid = Jid::default(); | ||||||||||||||||||||||||||||
| let own_jid = device_snapshot.pn.as_ref().unwrap_or(&default_jid); | ||||||||||||||||||||||||||||
| wacore::messages::parse_message_info(node, own_jid, device_snapshot.lid.as_ref()) | ||||||||||||||||||||||||||||
| let own_jid = own_pn.as_ref().unwrap_or(&default_jid); | ||||||||||||||||||||||||||||
| wacore::messages::parse_message_info(node, own_jid, own_lid.as_ref()) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| pub(crate) async fn handle_app_state_sync_key_share( | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to keep device reads on the snapshot path
Line 3584 and Line 3604 now read through
get_device_arc().read(). That breaks the repo’s state-access contract for reads. Move both getters back toget_device_snapshot().await(or an explicitly approved accessor that preserves the same contract).Suggested fix
pub async fn get_push_name(&self) -> String { self.persistence_manager - .get_device_arc() - .await - .read() + .get_device_snapshot() .await .push_name .clone() } @@ pub async fn get_lid(&self) -> Option<Jid> { self.persistence_manager - .get_device_arc() - .await - .read() + .get_device_snapshot() .await .lid .clone() }As per coding guidelines: Never modify Device state directly; always use
DeviceCommand+PersistenceManager::process_command()for state mutations andget_device_snapshot()for reading state.Also applies to: 3604-3610
🤖 Prompt for AI Agents