From cb04cefb2ae038466ccfcbd6103447432c07106b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Urbanek?= Date: Tue, 7 Jul 2026 13:45:41 +0200 Subject: [PATCH] chore: Update hotpath (#2412) --- Cargo.lock | 16 ++++++++-------- easytier/Cargo.toml | 2 +- easytier/src/hotpath_off.rs | 12 ++++++++++++ easytier/src/lib.rs | 2 ++ easytier/src/peers/mod.rs | 4 ++-- easytier/src/tests/ipv6_test.rs | 2 +- easytier/src/tunnel/fake_tcp/stack.rs | 8 ++++---- easytier/src/tunnel/mpsc.rs | 3 ++- easytier/src/tunnel/ring.rs | 3 ++- easytier/src/tunnel/udp.rs | 7 +++---- easytier/src/tunnel/wireguard.rs | 4 ++-- 11 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e326d9e4..b810e31a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4007,9 +4007,9 @@ dependencies = [ [[package]] name = "hotpath" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467479f30ae7262ad93eff1f6653a58ecfca4b44dd9ff82ef4b469ba1ad00017" +checksum = "1ff6b552a6afa29d9e33f8d555bee9093c142dd449501ae128e6494a303f03dc" dependencies = [ "arc-swap", "cfg-if", @@ -4036,9 +4036,9 @@ dependencies = [ [[package]] name = "hotpath-macros" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edb8da2a00454786fbb75ab24c4f72380afeb9b5136776caa7737df9895bfa7" +checksum = "4f15322569d3cfadf84c0de7ef72be435b8f4b4839ee4ace78a7eaca48a87ded" dependencies = [ "proc-macro2", "quote", @@ -4047,15 +4047,15 @@ dependencies = [ [[package]] name = "hotpath-macros-meta" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e804ccbbd13922ff16b752ab72043d15ea38411a03a82917b8ea5b36b6b45655" +checksum = "b3675e29d16c844ccad12763672b33e51d9a000c346720c4f354f7a3bdc649a8" [[package]] name = "hotpath-meta" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f76b1b9a176e5677878243b0c9052d2e0a62405359bd6990bbd85b59cafa2aa" +checksum = "d558d972ddc9483fb4e713af3dd41634edf895c7cb18ed13dc58c56431d42e27" dependencies = [ "hotpath-macros-meta", ] diff --git a/easytier/Cargo.toml b/easytier/Cargo.toml index 0cfafad9..9d95d80b 100644 --- a/easytier/Cargo.toml +++ b/easytier/Cargo.toml @@ -58,7 +58,7 @@ chrono = { version = "0.4.37", features = ["serde"] } guarden = "0.2" quanta = "0.12" -hotpath = { version = "0.19", default-features = false, optional = true } +hotpath = { version = "0.21", default-features = false, optional = true } delegate = "0.13.5" diff --git a/easytier/src/hotpath_off.rs b/easytier/src/hotpath_off.rs index 0ad97020..9346d02c 100644 --- a/easytier/src/hotpath_off.rs +++ b/easytier/src/hotpath_off.rs @@ -38,3 +38,15 @@ macro_rules! rw_lock { $expr }; } + +/// Type-level mirror of `hotpath::wrap` for type positions: with the feature +/// off, `channel!` returns the original endpoints, so the wrapped endpoint +/// types are the plain channel types. +pub(crate) mod wrap { + pub(crate) mod tokio { + pub(crate) mod sync { + pub(crate) use ::tokio::sync::mpsc; + } + } + pub(crate) use ::flume; +} diff --git a/easytier/src/lib.rs b/easytier/src/lib.rs index f2a814dd..c4cc116a 100644 --- a/easytier/src/lib.rs +++ b/easytier/src/lib.rs @@ -13,6 +13,8 @@ use clap_complete::{Generator, Shell}; extern crate self as hotpath; #[cfg(not(feature = "hotpath"))] mod hotpath_off; +#[cfg(not(feature = "hotpath"))] +pub(crate) use hotpath_off::wrap; // `hotpath-alloc` registers a global profiling allocator, which is mutually // exclusive with the `jemalloc`/`mimalloc` global allocators. diff --git a/easytier/src/peers/mod.rs b/easytier/src/peers/mod.rs index b08a76c3..e32d6d74 100644 --- a/easytier/src/peers/mod.rs +++ b/easytier/src/peers/mod.rs @@ -56,8 +56,8 @@ type BoxNicPacketFilter = Box; // pub fn create_packet_recv_chan() -> (PacketRecvChan, PacketRecvChanReceiver) { // tachyonix::channel(128) // } -pub type PacketRecvChan = tokio::sync::mpsc::Sender; -pub type PacketRecvChanReceiver = tokio::sync::mpsc::Receiver; +pub type PacketRecvChan = hotpath::wrap::tokio::sync::mpsc::Sender; +pub type PacketRecvChanReceiver = hotpath::wrap::tokio::sync::mpsc::Receiver; pub fn create_packet_recv_chan() -> (PacketRecvChan, PacketRecvChanReceiver) { hotpath::channel!(tokio::sync::mpsc::channel(128)) } diff --git a/easytier/src/tests/ipv6_test.rs b/easytier/src/tests/ipv6_test.rs index e953a521..e38db84e 100644 --- a/easytier/src/tests/ipv6_test.rs +++ b/easytier/src/tests/ipv6_test.rs @@ -49,7 +49,7 @@ async fn test_route_peer_info_ipv6() { #[tokio::test] async fn test_peer_manager_ipv6() { let global_ctx = get_mock_global_ctx(); - let (packet_sender, _packet_receiver) = tokio::sync::mpsc::channel(100); + let (packet_sender, _packet_receiver) = crate::peers::create_packet_recv_chan(); let peer_mgr = crate::peers::peer_manager::PeerManager::new( RouteAlgoType::Ospf, global_ctx.clone(), diff --git a/easytier/src/tunnel/fake_tcp/stack.rs b/easytier/src/tunnel/fake_tcp/stack.rs index b7387704..16c5f282 100644 --- a/easytier/src/tunnel/fake_tcp/stack.rs +++ b/easytier/src/tunnel/fake_tcp/stack.rs @@ -89,7 +89,7 @@ impl AddrTuple { #[derive(Default)] struct StackState { - tuples: HashMap>, + tuples: HashMap>, closed: bool, } @@ -133,7 +133,7 @@ pub enum State { pub struct Socket { shared: Arc, tun: Arc, - incoming: flume::Receiver, + incoming: hotpath::wrap::flume::Receiver, local_addr: SocketAddr, remote_addr: SocketAddr, local_mac: MacAddr, @@ -162,7 +162,7 @@ impl Socket { remote_mac: Option, ack: Option, state: State, - ) -> (Socket, flume::Sender) { + ) -> (Socket, hotpath::wrap::flume::Sender) { let (incoming_tx, incoming_rx) = hotpath::channel!(flume::bounded(MPMC_BUFFER_LEN)); ( @@ -505,7 +505,7 @@ impl Stack { shared: Arc, mut tuples_purge: broadcast::Receiver, ) { - let mut tuples: HashMap> = HashMap::new(); + let mut tuples: HashMap> = HashMap::new(); loop { let mut buf = BytesMut::new(); diff --git a/easytier/src/tunnel/mpsc.rs b/easytier/src/tunnel/mpsc.rs index 1d95b4c9..acfebb6a 100644 --- a/easytier/src/tunnel/mpsc.rs +++ b/easytier/src/tunnel/mpsc.rs @@ -9,7 +9,8 @@ use crate::proto::common::TunnelInfo; use super::{Tunnel, TunnelError, ZCPacketSink, ZCPacketStream, packet_def::ZCPacket}; -use tokio::sync::mpsc::{Receiver, Sender, channel, error::TrySendError}; +use hotpath::wrap::tokio::sync::mpsc::{Receiver, Sender}; +use tokio::sync::mpsc::{channel, error::TrySendError}; use tokio_util::task::AbortOnDropHandle; // use tachyonix::{channel, Receiver, Sender, TrySendError}; diff --git a/easytier/src/tunnel/ring.rs b/easytier/src/tunnel/ring.rs index 4f0fb324..ed6d8e01 100644 --- a/easytier/src/tunnel/ring.rs +++ b/easytier/src/tunnel/ring.rs @@ -11,7 +11,8 @@ use async_trait::async_trait; use futures::{Sink, SinkExt, Stream, StreamExt}; use once_cell::sync::Lazy; -use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel}; +use hotpath::wrap::tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use tokio::sync::mpsc::unbounded_channel; use uuid::Uuid; diff --git a/easytier/src/tunnel/udp.rs b/easytier/src/tunnel/udp.rs index fc78329a..69615c4b 100644 --- a/easytier/src/tunnel/udp.rs +++ b/easytier/src/tunnel/udp.rs @@ -13,11 +13,10 @@ use futures::{StreamExt, stream::FuturesUnordered}; use rand::{Rng, SeedableRng}; use zerocopy::{AsBytes, FromBytes}; +use hotpath::wrap::tokio::sync::mpsc::{Receiver, Sender, UnboundedReceiver, UnboundedSender}; use tokio::{ net::UdpSocket, - sync::mpsc::{ - Receiver, Sender, UnboundedReceiver, UnboundedSender, channel, unbounded_channel, - }, + sync::mpsc::{channel, unbounded_channel}, task::JoinSet, }; use tokio_util::task::AbortOnDropHandle; @@ -1185,7 +1184,7 @@ mod tests { let dst_addr = "127.0.0.1:1".parse().unwrap(); let ring_for_send_udp = Arc::new(RingTunnel::new(8)); let ring_for_recv_udp = Arc::new(RingTunnel::new(8)); - let (close_event_sender, _close_event_recv) = tokio::sync::mpsc::unbounded_channel(); + let (close_event_sender, _close_event_recv) = hotpath::channel!(tokio::sync::mpsc::unbounded_channel()); let mut conn = UdpConnection::new( socket, 7, diff --git a/easytier/src/tunnel/wireguard.rs b/easytier/src/tunnel/wireguard.rs index 3c1da62e..23140eea 100644 --- a/easytier/src/tunnel/wireguard.rs +++ b/easytier/src/tunnel/wireguard.rs @@ -465,8 +465,8 @@ impl WgPeer { } } -type ConnSender = tokio::sync::mpsc::UnboundedSender>; -type ConnReceiver = tokio::sync::mpsc::UnboundedReceiver>; +type ConnSender = hotpath::wrap::tokio::sync::mpsc::UnboundedSender>; +type ConnReceiver = hotpath::wrap::tokio::sync::mpsc::UnboundedReceiver>; pub struct WgTunnelListener { addr: url::Url,