hotpath: add measure to try_compress_and_encrypt and get_msg_dst_peer_ipv4

Splits the 1.04us gap between send_msg_by_ip and send_msg_internal:

  try_compress_and_encrypt:     386ns (37%)  ← AES-GCM encrypt + zstd compress
  get_msg_dst_peer_ipv4:        161ns (15%)  ← IP→peer_id route lookup
  run_nic_packet_process_pipeline: 121ns (12%) ← ACL check
  other (fill_hdr + counters):  ~440ns (36%)

The 386ns encrypt is the largest optimization opportunity in this gap:
ring tunnel is in-process, so application-layer encryption may be skippable.
This commit is contained in:
fanyang
2026-06-28 18:41:40 +08:00
parent 57cc9922a4
commit 368d140b5b
+2
View File
@@ -1633,6 +1633,7 @@ impl PeerManager {
.collect()
}
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerManager"))]
pub async fn get_msg_dst_peer_ipv4(&self, ipv4_addr: &Ipv4Addr) -> (Vec<PeerId>, bool) {
let mut is_exit_node = false;
let mut dst_peers = vec![];
@@ -1701,6 +1702,7 @@ impl PeerManager {
(dst_peers, is_exit_node)
}
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerManager"))]
pub async fn try_compress_and_encrypt(
compress_algo: CompressorAlgo,
encryptor: &Arc<dyn Encryptor + 'static>,