mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 09:09:17 +00:00
refactor(core): remove hotpath profiling (#2394)
hotpath adds noticeable overhead on hot paths, so remove the optional profiling integration while keeping direct quanta::Instant timing.
This commit is contained in:
Generated
-157
@@ -257,12 +257,6 @@ version = "0.7.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ascii"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-broadcast"
|
name = "async-broadcast"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
@@ -1254,12 +1248,6 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "chunked_transfer"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cidr"
|
name = "cidr"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -2100,16 +2088,6 @@ dependencies = [
|
|||||||
"dirs-sys 0.5.0",
|
"dirs-sys 0.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-next"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"dirs-sys-next",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys"
|
name = "dirs-sys"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
@@ -2133,17 +2111,6 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-sys-next"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"redox_users 0.4.5",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch2"
|
name = "dispatch2"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -2322,7 +2289,6 @@ dependencies = [
|
|||||||
"hickory-resolver",
|
"hickory-resolver",
|
||||||
"hickory-server",
|
"hickory-server",
|
||||||
"hmac",
|
"hmac",
|
||||||
"hotpath",
|
|
||||||
"http",
|
"http",
|
||||||
"http_req",
|
"http_req",
|
||||||
"humansize",
|
"humansize",
|
||||||
@@ -2665,12 +2631,6 @@ version = "1.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
|
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "encode_unicode"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding"
|
name = "encoding"
|
||||||
version = "0.2.33"
|
version = "0.2.33"
|
||||||
@@ -3929,61 +3889,6 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hotpath"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dc2c28b1fa962e433f800ed1ea0bf53dc028d3745cf2acec6cfd28b65ac96afa"
|
|
||||||
dependencies = [
|
|
||||||
"arc-swap",
|
|
||||||
"cfg-if",
|
|
||||||
"crossbeam-channel",
|
|
||||||
"flate2",
|
|
||||||
"flume 0.12.0",
|
|
||||||
"futures-util",
|
|
||||||
"hdrhistogram",
|
|
||||||
"hotpath-macros",
|
|
||||||
"hotpath-meta",
|
|
||||||
"libc",
|
|
||||||
"object",
|
|
||||||
"parking_lot",
|
|
||||||
"pin-project-lite",
|
|
||||||
"prettytable-rs",
|
|
||||||
"quanta",
|
|
||||||
"regex",
|
|
||||||
"rustc-demangle",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"tiny_http",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hotpath-macros"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a585238d8daf746e27df0f24d1bbdcd2410e9febff63f9a0173f90d7e71c50f6"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.117",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hotpath-macros-meta"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "309f63c2f755dead454dd4b3ea8ab5c947f14f8ea435fbcd37fa820e17290e80"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hotpath-meta"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "68faa91a9e1114dff668cd90560f332da6bbde40dae37ec28ea1c43ca5ce3be3"
|
|
||||||
dependencies = [
|
|
||||||
"hotpath-macros-meta",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "html5ever"
|
name = "html5ever"
|
||||||
version = "0.29.1"
|
version = "0.29.1"
|
||||||
@@ -4591,17 +4496,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "is-terminal"
|
|
||||||
version = "0.4.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
|
|
||||||
dependencies = [
|
|
||||||
"hermit-abi",
|
|
||||||
"libc",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is-wsl"
|
name = "is-wsl"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@@ -5952,15 +5846,6 @@ dependencies = [
|
|||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "object"
|
|
||||||
version = "0.36.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.3"
|
version = "1.21.3"
|
||||||
@@ -6831,19 +6716,6 @@ dependencies = [
|
|||||||
"syn 2.0.117",
|
"syn 2.0.117",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "prettytable-rs"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "eea25e07510aa6ab6547308ebe3c036016d162b8da920dbb079e3ba8acf3d95a"
|
|
||||||
dependencies = [
|
|
||||||
"encode_unicode",
|
|
||||||
"is-terminal",
|
|
||||||
"lazy_static",
|
|
||||||
"term",
|
|
||||||
"unicode-width 0.1.11",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "primeorder"
|
name = "primeorder"
|
||||||
version = "0.13.6"
|
version = "0.13.6"
|
||||||
@@ -7903,12 +7775,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-demangle"
|
|
||||||
version = "0.1.27"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@@ -9833,17 +9699,6 @@ dependencies = [
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "term"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-next",
|
|
||||||
"rustversion",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "terminal_size"
|
name = "terminal_size"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@@ -9999,18 +9854,6 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "825f6c8a18bc36d56a62f66af7296385b628c9c5543a8663d4c217fc920bfefd"
|
checksum = "825f6c8a18bc36d56a62f66af7296385b628c9c5543a8663d4c217fc920bfefd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tiny_http"
|
|
||||||
version = "0.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82"
|
|
||||||
dependencies = [
|
|
||||||
"ascii",
|
|
||||||
"chunked_transfer",
|
|
||||||
"httpdate",
|
|
||||||
"log",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinystr"
|
name = "tinystr"
|
||||||
version = "0.7.6"
|
version = "0.7.6"
|
||||||
|
|||||||
+6
-10
@@ -52,7 +52,6 @@ toml = "0.8.12"
|
|||||||
chrono = { version = "0.4.37", features = ["serde"] }
|
chrono = { version = "0.4.37", features = ["serde"] }
|
||||||
|
|
||||||
guarden = "0.2"
|
guarden = "0.2"
|
||||||
hotpath = { version = "0.18", default-features = false, optional = true }
|
|
||||||
quanta = "0.12"
|
quanta = "0.12"
|
||||||
|
|
||||||
delegate = "0.13.5"
|
delegate = "0.13.5"
|
||||||
@@ -403,17 +402,14 @@ jemalloc-prof = [
|
|||||||
"jemalloc-sys/stats",
|
"jemalloc-sys/stats",
|
||||||
]
|
]
|
||||||
tracing = ["tokio/tracing", "dep:console-subscriber"]
|
tracing = ["tokio/tracing", "dep:console-subscriber"]
|
||||||
hotpath = [
|
|
||||||
"dep:hotpath",
|
|
||||||
"hotpath/hotpath",
|
|
||||||
"hotpath/tokio",
|
|
||||||
"hotpath/parking_lot",
|
|
||||||
"hotpath/flume",
|
|
||||||
]
|
|
||||||
hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"]
|
|
||||||
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]
|
|
||||||
magic-dns = ["dep:hickory-client", "dep:hickory-server"]
|
magic-dns = ["dep:hickory-client", "dep:hickory-server"]
|
||||||
faketcp = ["dep:flume"]
|
faketcp = ["dep:flume"]
|
||||||
zstd = ["dep:zstd"]
|
zstd = ["dep:zstd"]
|
||||||
|
# Deprecated: hotpath profiling has been removed. These feature aliases are
|
||||||
|
# retained as no-ops so existing build scripts using `--features hotpath*`
|
||||||
|
# continue to work without pulling in any dependencies.
|
||||||
|
hotpath = []
|
||||||
|
hotpath-cpu = ["hotpath"]
|
||||||
|
hotpath-alloc = ["hotpath"]
|
||||||
# For Network Extension on macOS
|
# For Network Extension on macOS
|
||||||
macos-ne = []
|
macos-ne = []
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use crate::common::{config::ConfigLoader, global_ctx::ArcGlobalCtx, token_bucket::TokenBucket};
|
use crate::common::{config::ConfigLoader, global_ctx::ArcGlobalCtx, token_bucket::TokenBucket};
|
||||||
use crate::proto::acl::*;
|
use crate::proto::acl::*;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::proto::common::{NatType, StunInfo};
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use rand::seq::IteratorRandom;
|
use rand::seq::IteratorRandom;
|
||||||
use socket2::{SockAddr, SockRef};
|
use socket2::{SockAddr, SockRef};
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{
|
common::{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use dashmap::DashSet;
|
use dashmap::DashSet;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use tokio::{sync::mpsc, task::JoinSet, time::timeout};
|
use tokio::{sync::mpsc, task::JoinSet, time::timeout};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Error};
|
use anyhow::{Context, Error};
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use rand::Rng as _;
|
use rand::Rng as _;
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use std::{
|
|||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use dashmap::{DashMap, DashSet};
|
use dashmap::{DashMap, DashSet};
|
||||||
use guarden::defer;
|
use guarden::defer;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use rand::seq::SliceRandom as _;
|
use rand::seq::SliceRandom as _;
|
||||||
use tokio::{net::UdpSocket, sync::Mutex, task::JoinSet};
|
use tokio::{net::UdpSocket, sync::Mutex, task::JoinSet};
|
||||||
use tracing::{Instrument, Level, instrument};
|
use tracing::{Instrument, Level, instrument};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ use both_easy_sym::{PunchBothEasySymHoleClient, PunchBothEasySymHoleServer};
|
|||||||
use common::{PunchHoleServerCommon, UdpNatType, UdpPunchClientMethod};
|
use common::{PunchHoleServerCommon, UdpNatType, UdpPunchClientMethod};
|
||||||
use cone::{PunchConeHoleClient, PunchConeHoleServer};
|
use cone::{PunchConeHoleClient, PunchConeHoleServer};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use quanta::Instant;
|
||||||
use sym_to_cone::{PunchSymToConeHoleClient, PunchSymToConeHoleServer};
|
use sym_to_cone::{PunchSymToConeHoleClient, PunchSymToConeHoleServer};
|
||||||
use tokio::{sync::Mutex, task::JoinHandle};
|
use tokio::{sync::Mutex, task::JoinHandle};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use std::{
|
|||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use guarden::defer;
|
use guarden::defer;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use rand::{Rng, seq::SliceRandom};
|
use rand::{Rng, seq::SliceRandom};
|
||||||
use tokio::{net::UdpSocket, sync::RwLock};
|
use tokio::{net::UdpSocket, sync::RwLock};
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
use easytier::core;
|
use easytier::core;
|
||||||
|
|
||||||
#[cfg(all(
|
|
||||||
feature = "hotpath-alloc",
|
|
||||||
any(feature = "jemalloc", feature = "mimalloc")
|
|
||||||
))]
|
|
||||||
compile_error!("feature `hotpath-alloc` cannot be enabled together with `jemalloc` or `mimalloc`");
|
|
||||||
|
|
||||||
#[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
|
#[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
|
||||||
use mimalloc::MiMalloc;
|
use mimalloc::MiMalloc;
|
||||||
|
|
||||||
@@ -30,16 +24,6 @@ pub static malloc_conf: &[u8] = b"retain:false\0";
|
|||||||
rust_i18n::i18n!("locales", fallback = "en");
|
rust_i18n::i18n!("locales", fallback = "en");
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
#[cfg_attr(
|
|
||||||
all(
|
|
||||||
feature = "hotpath",
|
|
||||||
not(all(
|
|
||||||
feature = "hotpath-alloc",
|
|
||||||
any(feature = "jemalloc", feature = "mimalloc")
|
|
||||||
))
|
|
||||||
),
|
|
||||||
hotpath::main
|
|
||||||
)]
|
|
||||||
async fn main() -> std::process::ExitCode {
|
async fn main() -> std::process::ExitCode {
|
||||||
core::main().await
|
core::main().await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use pnet::packet::{
|
use pnet::packet::{
|
||||||
Packet,
|
Packet,
|
||||||
icmp::{self, IcmpCode, IcmpTypes, MutableIcmpPacket, echo_reply::MutableEchoReplyPacket},
|
icmp::{self, IcmpCode, IcmpTypes, MutableIcmpPacket, echo_reply::MutableEchoReplyPacket},
|
||||||
ip::IpNextHeaderProtocols,
|
ip::IpNextHeaderProtocols,
|
||||||
ipv4::Ipv4Packet,
|
ipv4::Ipv4Packet,
|
||||||
};
|
};
|
||||||
|
use quanta::Instant;
|
||||||
use socket2::Socket;
|
use socket2::Socket;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
sync::{Mutex, mpsc::UnboundedSender},
|
sync::{Mutex, mpsc::UnboundedSender},
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use pnet::packet::Packet;
|
use pnet::packet::Packet;
|
||||||
use pnet::packet::ip::IpNextHeaderProtocol;
|
use pnet::packet::ip::IpNextHeaderProtocol;
|
||||||
use pnet::packet::ipv4::{self, Ipv4Flags, Ipv4Packet, MutableIpv4Packet};
|
use pnet::packet::ipv4::{self, Ipv4Flags, Ipv4Packet, MutableIpv4Packet};
|
||||||
|
use quanta::Instant;
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
|||||||
@@ -1018,7 +1018,7 @@ impl TcpProxyRpc for QuicProxyDstRpcService {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bytes::Buf;
|
use bytes::Buf;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
/// Helper function: Create a pair of interconnected QuicSockets.
|
/// Helper function: Create a pair of interconnected QuicSockets.
|
||||||
/// Data sent by socket_a will enter socket_b's rx, and vice versa.
|
/// Data sent by socket_a will enter socket_b's rx, and vice versa.
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
#[cfg(feature = "kcp")]
|
#[cfg(feature = "kcp")]
|
||||||
use kcp_sys::{endpoint::KcpEndpoint, stream::KcpStream};
|
use kcp_sys::{endpoint::KcpEndpoint, stream::KcpStream};
|
||||||
|
use quanta::Instant;
|
||||||
use tokio_util::sync::{CancellationToken, DropGuard};
|
use tokio_util::sync::{CancellationToken, DropGuard};
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite};
|
use tokio::io::{AsyncRead, AsyncWrite};
|
||||||
|
|
||||||
use crate::{common::error::Error, gateway::fast_socks5::server::AsyncTcpConnector};
|
use crate::{common::error::Error, gateway::fast_socks5::server::AsyncTcpConnector};
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ use cidr::Ipv4Inet;
|
|||||||
use core::panic;
|
use core::panic;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use pnet::packet::MutablePacket;
|
use pnet::packet::MutablePacket;
|
||||||
use pnet::packet::Packet;
|
use pnet::packet::Packet;
|
||||||
use pnet::packet::ip::IpNextHeaderProtocols;
|
use pnet::packet::ip::IpNextHeaderProtocols;
|
||||||
use pnet::packet::ipv4::{Ipv4Packet, MutableIpv4Packet};
|
use pnet::packet::ipv4::{Ipv4Packet, MutableIpv4Packet};
|
||||||
use pnet::packet::tcp::{MutableTcpPacket, TcpPacket, ipv4_checksum};
|
use pnet::packet::tcp::{MutableTcpPacket, TcpPacket, ipv4_checksum};
|
||||||
|
use quanta::Instant;
|
||||||
use socket2::{SockRef, TcpKeepalive};
|
use socket2::{SockRef, TcpKeepalive};
|
||||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU16};
|
use std::sync::atomic::{AtomicBool, AtomicU16};
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ use bytes::{BufMut, BytesMut};
|
|||||||
use cidr::Ipv4Inet;
|
use cidr::Ipv4Inet;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use pnet::packet::{
|
use pnet::packet::{
|
||||||
Packet,
|
Packet,
|
||||||
ip::IpNextHeaderProtocols,
|
ip::IpNextHeaderProtocols,
|
||||||
ipv4::Ipv4Packet,
|
ipv4::Ipv4Packet,
|
||||||
udp::{self, MutableUdpPacket},
|
udp::{self, MutableUdpPacket},
|
||||||
};
|
};
|
||||||
|
use quanta::Instant;
|
||||||
use tokio::sync::mpsc::{Receiver, Sender, channel, error::TrySendError};
|
use tokio::sync::mpsc::{Receiver, Sender, channel, error::TrySendError};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
net::UdpSocket,
|
net::UdpSocket,
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
//! No-op stand-in for the `hotpath` macros used by this crate, selected when
|
|
||||||
//! the `hotpath` feature is disabled.
|
|
||||||
//!
|
|
||||||
//! Keeping `hotpath` as an optional dependency means default builds do not pull
|
|
||||||
//! the profiler (or any of its transitive dependencies) into the dependency
|
|
||||||
//! graph. These macros expand to their input unchanged, mirroring `hotpath`'s
|
|
||||||
//! own disabled mode so call sites compile identically with or without the
|
|
||||||
//! feature.
|
|
||||||
//!
|
|
||||||
//! The macros are `#[macro_export]`-ed so that `lib.rs`' `extern crate self as
|
|
||||||
//! hotpath` alias exposes them through the same `hotpath::...` paths used when
|
|
||||||
//! the feature is enabled.
|
|
||||||
|
|
||||||
/// No-op mirroring `hotpath::channel!`: returns the channel expression
|
|
||||||
/// unchanged (dropping any optional trailing `label`/`log`/`capacity` args).
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! channel {
|
|
||||||
($expr:expr $(, $($rest:tt)*)?) => {
|
|
||||||
$expr
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// No-op mirroring `hotpath::mutex!`: returns the expression unchanged.
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! mutex {
|
|
||||||
($expr:expr $(, $($rest:tt)*)?) => {
|
|
||||||
$expr
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// No-op mirroring `hotpath::rw_lock!`: returns the expression unchanged.
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! rw_lock {
|
|
||||||
($expr:expr $(, $($rest:tt)*)?) => {
|
|
||||||
$expr
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ use std::sync::{Arc, Weak};
|
|||||||
|
|
||||||
use crate::common::global_ctx::{ArcGlobalCtx, GlobalCtxEvent};
|
use crate::common::global_ctx::{ArcGlobalCtx, GlobalCtxEvent};
|
||||||
use crate::peers::peer_manager::PeerManager;
|
use crate::peers::peer_manager::PeerManager;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|
||||||
/// ProxyCidrsMonitor monitors changes in proxy CIDRs from peer routes
|
/// ProxyCidrsMonitor monitors changes in proxy CIDRs from peer routes
|
||||||
|
|||||||
+1
-20
@@ -5,29 +5,10 @@ use std::io;
|
|||||||
use clap::Command;
|
use clap::Command;
|
||||||
use clap_complete::{Generator, Shell};
|
use clap_complete::{Generator, Shell};
|
||||||
|
|
||||||
// When the `hotpath` feature is off, alias the current crate as `hotpath` so
|
|
||||||
// call sites keep using `hotpath::...` paths, and provide a local no-op shim
|
|
||||||
// for the profiling macros. This keeps `hotpath` an optional dependency: the
|
|
||||||
// profiler is absent from the dependency graph entirely in default builds.
|
|
||||||
#[cfg(not(feature = "hotpath"))]
|
|
||||||
extern crate self as hotpath;
|
|
||||||
#[cfg(not(feature = "hotpath"))]
|
|
||||||
mod hotpath_off;
|
|
||||||
|
|
||||||
// When the `hotpath` feature is off, expose a local `instant` module backed by
|
|
||||||
// `quanta::Instant` so call sites can uniformly write `use hotpath::instant::Instant;`
|
|
||||||
// regardless of whether the feature is enabled. With the feature on, the real
|
|
||||||
// `hotpath` crate provides the same path (also `quanta::Instant` on Linux), so
|
|
||||||
// the two modes resolve to the identical type.
|
|
||||||
#[cfg(not(feature = "hotpath"))]
|
|
||||||
pub mod instant {
|
|
||||||
pub type Instant = quanta::Instant;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-export `Instant` at the crate root so public APIs that expose it
|
// Re-export `Instant` at the crate root so public APIs that expose it
|
||||||
// (e.g. `Route::get_peer_info_last_update_time`) reference a deliberate
|
// (e.g. `Route::get_peer_info_last_update_time`) reference a deliberate
|
||||||
// public type rather than leaking an inaccessible one.
|
// public type rather than leaking an inaccessible one.
|
||||||
pub use hotpath::instant::Instant;
|
pub use quanta::Instant;
|
||||||
|
|
||||||
mod arch;
|
mod arch;
|
||||||
mod gateway;
|
mod gateway;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ use std::{
|
|||||||
|
|
||||||
use arc_swap::ArcSwap;
|
use arc_swap::ArcSwap;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use pnet::packet::ipv6::Ipv6Packet;
|
use pnet::packet::ipv6::Ipv6Packet;
|
||||||
use pnet::packet::{
|
use pnet::packet::{
|
||||||
Packet as _, ip::IpNextHeaderProtocols, ipv4::Ipv4Packet, tcp::TcpPacket, udp::UdpPacket,
|
Packet as _, ip::IpNextHeaderProtocols, ipv4::Ipv4Packet, tcp::TcpPacket, udp::UdpPacket,
|
||||||
};
|
};
|
||||||
|
use quanta::Instant;
|
||||||
|
|
||||||
use crate::proto::acl::{AclStats, Protocol};
|
use crate::proto::acl::{AclStats, Protocol};
|
||||||
use crate::tunnel::packet_def::PacketType;
|
use crate::tunnel::packet_def::PacketType;
|
||||||
@@ -404,7 +404,7 @@ mod tests {
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::acl_processor::PacketInfo,
|
common::acl_processor::PacketInfo,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ type BoxNicPacketFilter = Box<dyn NicPacketFilter + Send + Sync>;
|
|||||||
pub type PacketRecvChan = tokio::sync::mpsc::Sender<ZCPacket>;
|
pub type PacketRecvChan = tokio::sync::mpsc::Sender<ZCPacket>;
|
||||||
pub type PacketRecvChanReceiver = tokio::sync::mpsc::Receiver<ZCPacket>;
|
pub type PacketRecvChanReceiver = tokio::sync::mpsc::Receiver<ZCPacket>;
|
||||||
pub fn create_packet_recv_chan() -> (PacketRecvChan, PacketRecvChanReceiver) {
|
pub fn create_packet_recv_chan() -> (PacketRecvChan, PacketRecvChanReceiver) {
|
||||||
hotpath::channel!(tokio::sync::mpsc::channel(128))
|
tokio::sync::mpsc::channel(128)
|
||||||
}
|
}
|
||||||
pub async fn recv_packet_from_chan(
|
pub async fn recv_packet_from_chan(
|
||||||
packet_recv_chan_receiver: &mut PacketRecvChanReceiver,
|
packet_recv_chan_receiver: &mut PacketRecvChanReceiver,
|
||||||
|
|||||||
@@ -207,7 +207,6 @@ impl Peer {
|
|||||||
.map(|conn| conn.clone())
|
.map(|conn| conn.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "Peer"))]
|
|
||||||
pub async fn send_msg(&self, msg: ZCPacket) -> Result<(), Error> {
|
pub async fn send_msg(&self, msg: ZCPacket) -> Result<(), Error> {
|
||||||
let Some(conn) = self.select_conn().await else {
|
let Some(conn) = self.select_conn().await else {
|
||||||
return Err(Error::PeerNoConnectionError(self.peer_node_id));
|
return Err(Error::PeerNoConnectionError(self.peer_node_id));
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ use std::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "hotpath")]
|
|
||||||
use hotpath::wrap::tokio::sync::Mutex;
|
|
||||||
#[cfg(not(feature = "hotpath"))]
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
@@ -384,12 +381,12 @@ impl PeerConn {
|
|||||||
session_filter,
|
session_filter,
|
||||||
noise_handshake_result: None,
|
noise_handshake_result: None,
|
||||||
|
|
||||||
tunnel: Arc::new(hotpath::mutex!(tokio::sync::Mutex::new(Box::new(
|
tunnel: Arc::new(Mutex::new(
|
||||||
guard!([mut mpsc_tunnel] mpsc_tunnel.close()),
|
Box::new(guard!([mut mpsc_tunnel] mpsc_tunnel.close()))
|
||||||
)
|
as Box<dyn Any + Send + 'static>,
|
||||||
as Box<dyn Any + Send + 'static>))),
|
)),
|
||||||
sink,
|
sink,
|
||||||
recv: hotpath::mutex!(tokio::sync::Mutex::new(Some(recv))),
|
recv: Mutex::new(Some(recv)),
|
||||||
tunnel_info,
|
tunnel_info,
|
||||||
|
|
||||||
tasks: JoinSet::new(),
|
tasks: JoinSet::new(),
|
||||||
@@ -1466,7 +1463,6 @@ impl PeerConn {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerConn"))]
|
|
||||||
pub async fn send_msg(&self, msg: ZCPacket) -> Result<(), Error> {
|
pub async fn send_msg(&self, msg: ZCPacket) -> Result<(), Error> {
|
||||||
Ok(self.sink.send(msg).await?)
|
Ok(self.sink.send(msg).await?)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use rand::{Rng, thread_rng};
|
use rand::{Rng, thread_rng};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
sync::broadcast,
|
sync::broadcast,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use anyhow::Context;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cidr::{Ipv4Cidr, Ipv6Cidr};
|
use cidr::{Ipv4Cidr, Ipv6Cidr};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
@@ -11,9 +11,6 @@ use std::{
|
|||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "hotpath")]
|
|
||||||
use hotpath::wrap::tokio::sync::{Mutex, RwLock};
|
|
||||||
#[cfg(not(feature = "hotpath"))]
|
|
||||||
use tokio::sync::{Mutex, RwLock};
|
use tokio::sync::{Mutex, RwLock};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
sync::mpsc::{self, UnboundedReceiver, UnboundedSender},
|
sync::mpsc::{self, UnboundedReceiver, UnboundedSender},
|
||||||
@@ -279,8 +276,8 @@ impl PeerManager {
|
|||||||
let rpc_tspt = Arc::new(RpcTransport {
|
let rpc_tspt = Arc::new(RpcTransport {
|
||||||
my_peer_id,
|
my_peer_id,
|
||||||
peers: Arc::downgrade(&peers),
|
peers: Arc::downgrade(&peers),
|
||||||
foreign_peers: hotpath::mutex!(tokio::sync::Mutex::new(None)),
|
foreign_peers: Mutex::new(None),
|
||||||
packet_recv: hotpath::mutex!(tokio::sync::Mutex::new(peer_rpc_tspt_recv)),
|
packet_recv: Mutex::new(peer_rpc_tspt_recv),
|
||||||
peer_rpc_tspt_sender,
|
peer_rpc_tspt_sender,
|
||||||
encryptor: encryptor.clone(),
|
encryptor: encryptor.clone(),
|
||||||
is_secure_mode_enabled,
|
is_secure_mode_enabled,
|
||||||
@@ -412,21 +409,17 @@ impl PeerManager {
|
|||||||
global_ctx,
|
global_ctx,
|
||||||
nic_channel,
|
nic_channel,
|
||||||
|
|
||||||
tasks: hotpath::mutex!(tokio::sync::Mutex::new(JoinSet::new())),
|
tasks: Mutex::new(JoinSet::new()),
|
||||||
|
|
||||||
packet_recv: Arc::new(hotpath::mutex!(tokio::sync::Mutex::new(Some(packet_recv)))),
|
packet_recv: Arc::new(Mutex::new(Some(packet_recv))),
|
||||||
|
|
||||||
peers,
|
peers,
|
||||||
|
|
||||||
peer_rpc_mgr,
|
peer_rpc_mgr,
|
||||||
peer_rpc_tspt: rpc_tspt,
|
peer_rpc_tspt: rpc_tspt,
|
||||||
|
|
||||||
peer_packet_process_pipeline: Arc::new(hotpath::rw_lock!(tokio::sync::RwLock::new(
|
peer_packet_process_pipeline: Arc::new(RwLock::new(Vec::new())),
|
||||||
Vec::new()
|
nic_packet_process_pipeline: Arc::new(RwLock::new(Vec::new())),
|
||||||
))),
|
|
||||||
nic_packet_process_pipeline: Arc::new(hotpath::rw_lock!(tokio::sync::RwLock::new(
|
|
||||||
Vec::new()
|
|
||||||
))),
|
|
||||||
|
|
||||||
route_algo_inst,
|
route_algo_inst,
|
||||||
|
|
||||||
@@ -437,7 +430,7 @@ impl PeerManager {
|
|||||||
encryptor,
|
encryptor,
|
||||||
data_compress_algo,
|
data_compress_algo,
|
||||||
|
|
||||||
exit_nodes: hotpath::rw_lock!(tokio::sync::RwLock::new(exit_nodes)),
|
exit_nodes: RwLock::new(exit_nodes),
|
||||||
|
|
||||||
reserved_my_peer_id_map: DashMap::new(),
|
reserved_my_peer_id_map: DashMap::new(),
|
||||||
recent_have_traffic: Arc::new(DashMap::new()),
|
recent_have_traffic: Arc::new(DashMap::new()),
|
||||||
@@ -1444,7 +1437,6 @@ impl PeerManager {
|
|||||||
self.get_route().get_foreign_network_summary().await
|
self.get_route().get_foreign_network_summary().await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerManager"))]
|
|
||||||
async fn run_nic_packet_process_pipeline(&self, data: &mut ZCPacket) -> bool {
|
async fn run_nic_packet_process_pipeline(&self, data: &mut ZCPacket) -> bool {
|
||||||
// Enforce ACL for outbound (NIC-originated) packets. If ACL denies, stop processing.
|
// Enforce ACL for outbound (NIC-originated) packets. If ACL denies, stop processing.
|
||||||
if !self.global_ctx.get_acl_filter().process_packet_with_acl(
|
if !self.global_ctx.get_acl_filter().process_packet_with_acl(
|
||||||
@@ -1530,7 +1522,6 @@ impl PeerManager {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerManager"))]
|
|
||||||
async fn send_msg_internal(
|
async fn send_msg_internal(
|
||||||
peers: &Arc<PeerMap>,
|
peers: &Arc<PeerMap>,
|
||||||
foreign_network_client: &Arc<ForeignNetworkClient>,
|
foreign_network_client: &Arc<ForeignNetworkClient>,
|
||||||
@@ -2207,7 +2198,7 @@ mod tests {
|
|||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use std::{collections::HashMap, fmt::Debug, sync::Arc, time::Duration};
|
use std::{collections::HashMap, fmt::Debug, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{
|
common::{
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ impl PeerMap {
|
|||||||
peer_id == self.my_peer_id || self.peer_map.contains_key(&peer_id)
|
peer_id == self.my_peer_id || self.peer_map.contains_key(&peer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerMap"))]
|
|
||||||
pub async fn send_msg_directly(&self, msg: ZCPacket, dst_peer_id: PeerId) -> Result<(), Error> {
|
pub async fn send_msg_directly(&self, msg: ZCPacket, dst_peer_id: PeerId) -> Result<(), Error> {
|
||||||
if dst_peer_id == self.my_peer_id {
|
if dst_peer_id == self.my_peer_id {
|
||||||
let packet_send = self.packet_send.clone();
|
let packet_send = self.packet_send.clone();
|
||||||
@@ -164,7 +163,6 @@ impl PeerMap {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerMap"))]
|
|
||||||
pub async fn get_gateway_peer_id(
|
pub async fn get_gateway_peer_id(
|
||||||
&self,
|
&self,
|
||||||
dst_peer_id: PeerId,
|
dst_peer_id: PeerId,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use arc_swap::ArcSwap;
|
|||||||
use cidr::{IpCidr, Ipv4Cidr, Ipv6Cidr, Ipv6Inet};
|
use cidr::{IpCidr, Ipv4Cidr, Ipv6Cidr, Ipv6Inet};
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use ordered_hash_map::OrderedHashMap;
|
use ordered_hash_map::OrderedHashMap;
|
||||||
use parking_lot::{RwLock, lock_api::RwLockUpgradableReadGuard};
|
use parking_lot::{RwLock, lock_api::RwLockUpgradableReadGuard};
|
||||||
use petgraph::{
|
use petgraph::{
|
||||||
@@ -25,6 +24,7 @@ use petgraph::{
|
|||||||
use prefix_trie::PrefixMap;
|
use prefix_trie::PrefixMap;
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
use prost_reflect::{DynamicMessage, ReflectMessage};
|
use prost_reflect::{DynamicMessage, ReflectMessage};
|
||||||
|
use quanta::Instant;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
select,
|
select,
|
||||||
sync::Mutex,
|
sync::Mutex,
|
||||||
@@ -1394,7 +1394,6 @@ impl RouteTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "RouteTable"))]
|
|
||||||
fn get_next_hop(&self, dst_peer_id: PeerId) -> Option<NextHopInfo> {
|
fn get_next_hop(&self, dst_peer_id: PeerId) -> Option<NextHopInfo> {
|
||||||
if self.suppressed_peer_ids.contains_key(&dst_peer_id) {
|
if self.suppressed_peer_ids.contains_key(&dst_peer_id) {
|
||||||
return None;
|
return None;
|
||||||
@@ -1402,7 +1401,6 @@ impl RouteTable {
|
|||||||
self.get_topology_next_hop(dst_peer_id)
|
self.get_topology_next_hop(dst_peer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "RouteTable"))]
|
|
||||||
fn get_topology_next_hop(&self, dst_peer_id: PeerId) -> Option<NextHopInfo> {
|
fn get_topology_next_hop(&self, dst_peer_id: PeerId) -> Option<NextHopInfo> {
|
||||||
let cur_version = self.next_hop_map_version.get();
|
let cur_version = self.next_hop_map_version.get();
|
||||||
self.next_hop_map.get(&dst_peer_id).and_then(|x| {
|
self.next_hop_map.get(&dst_peer_id).and_then(|x| {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use std::time::Duration;
|
|||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use super::secure_datagram::{SecureDatagramDirection, SecureDatagramSession};
|
use super::secure_datagram::{SecureDatagramDirection, SecureDatagramSession};
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -376,7 +376,6 @@ impl PeerSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerSession"))]
|
|
||||||
pub fn encrypt_payload(
|
pub fn encrypt_payload(
|
||||||
&self,
|
&self,
|
||||||
sender_peer_id: PeerId,
|
sender_peer_id: PeerId,
|
||||||
@@ -390,7 +389,6 @@ impl PeerSession {
|
|||||||
.encrypt_payload(Self::dir_for_sender(sender_peer_id, receiver_peer_id), pkt)
|
.encrypt_payload(Self::dir_for_sender(sender_peer_id, receiver_peer_id), pkt)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "PeerSession"))]
|
|
||||||
pub fn decrypt_payload(
|
pub fn decrypt_payload(
|
||||||
&self,
|
&self,
|
||||||
sender_peer_id: PeerId,
|
sender_peer_id: PeerId,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
|
use quanta::Instant;
|
||||||
use snow::params::NoiseParams;
|
use snow::params::NoiseParams;
|
||||||
use tokio::sync::{Mutex, OwnedMutexGuard, oneshot};
|
use tokio::sync::{Mutex, OwnedMutexGuard, oneshot};
|
||||||
use tokio::time::{Duration, timeout};
|
use tokio::time::{Duration, timeout};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use cidr::Ipv6Inet;
|
use cidr::Ipv6Inet;
|
||||||
use cidr::{Ipv4Cidr, Ipv6Cidr};
|
use cidr::{Ipv4Cidr, Ipv6Cidr};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
use std::{
|
use std::{
|
||||||
collections::BTreeSet,
|
collections::BTreeSet,
|
||||||
net::{Ipv4Addr, Ipv6Addr},
|
net::{Ipv4Addr, Ipv6Addr},
|
||||||
|
|||||||
@@ -701,10 +701,6 @@ impl SecureDatagramSession {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(
|
|
||||||
feature = "hotpath",
|
|
||||||
hotpath::measure(impl_type = "SecureDatagramSession")
|
|
||||||
)]
|
|
||||||
pub fn encrypt_payload(
|
pub fn encrypt_payload(
|
||||||
&self,
|
&self,
|
||||||
dir: SecureDatagramDirection,
|
dir: SecureDatagramDirection,
|
||||||
@@ -723,10 +719,6 @@ impl SecureDatagramSession {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(
|
|
||||||
feature = "hotpath",
|
|
||||||
hotpath::measure(impl_type = "SecureDatagramSession")
|
|
||||||
)]
|
|
||||||
pub fn decrypt_payload(
|
pub fn decrypt_payload(
|
||||||
&self,
|
&self,
|
||||||
dir: SecureDatagramDirection,
|
dir: SecureDatagramDirection,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use std::sync::{Arc, Mutex};
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use guarden::defer;
|
use guarden::defer;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
|
use quanta::Instant;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
use tokio::time::timeout;
|
use tokio::time::timeout;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use prost::{Message as _, length_delimiter_len};
|
use prost::{Message as _, length_delimiter_len};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{PeerId, compressor::DefaultCompressor},
|
common::{PeerId, compressor::DefaultCompressor},
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use std::{
|
|||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use hotpath::instant::Instant;
|
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
|
use quanta::Instant;
|
||||||
use tokio::{task::JoinSet, time::timeout};
|
use tokio::{task::JoinSet, time::timeout};
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ impl Socket {
|
|||||||
ack: Option<u32>,
|
ack: Option<u32>,
|
||||||
state: State,
|
state: State,
|
||||||
) -> (Socket, flume::Sender<Bytes>) {
|
) -> (Socket, flume::Sender<Bytes>) {
|
||||||
let (incoming_tx, incoming_rx) = hotpath::channel!(flume::bounded(MPMC_BUFFER_LEN));
|
let (incoming_tx, incoming_rx) = flume::bounded(MPMC_BUFFER_LEN);
|
||||||
|
|
||||||
(
|
(
|
||||||
Socket {
|
Socket {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ pub struct MpscTunnel<T> {
|
|||||||
|
|
||||||
impl<T: Tunnel> MpscTunnel<T> {
|
impl<T: Tunnel> MpscTunnel<T> {
|
||||||
pub fn new(tunnel: T, send_timeout: Option<Duration>) -> Self {
|
pub fn new(tunnel: T, send_timeout: Option<Duration>) -> Self {
|
||||||
let (tx, mut rx) = hotpath::channel!(channel(32));
|
let (tx, mut rx) = channel(32);
|
||||||
let (stream, mut sink) = tunnel.split();
|
let (stream, mut sink) = tunnel.split();
|
||||||
|
|
||||||
let task = tokio::spawn(async move {
|
let task = tokio::spawn(async move {
|
||||||
@@ -66,7 +66,6 @@ impl<T: Tunnel> MpscTunnel<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "MpscTunnel"))]
|
|
||||||
async fn forward_one_round(
|
async fn forward_one_round(
|
||||||
rx: &mut Receiver<ZCPacket>,
|
rx: &mut Receiver<ZCPacket>,
|
||||||
sink: &mut Pin<Box<dyn ZCPacketSink>>,
|
sink: &mut Pin<Box<dyn ZCPacketSink>>,
|
||||||
@@ -80,7 +79,6 @@ impl<T: Tunnel> MpscTunnel<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "MpscTunnel"))]
|
|
||||||
async fn forward_one_round_no_timeout(
|
async fn forward_one_round_no_timeout(
|
||||||
rx: &mut Receiver<ZCPacket>,
|
rx: &mut Receiver<ZCPacket>,
|
||||||
sink: &mut Pin<Box<dyn ZCPacketSink>>,
|
sink: &mut Pin<Box<dyn ZCPacketSink>>,
|
||||||
@@ -98,7 +96,6 @@ impl<T: Tunnel> MpscTunnel<T> {
|
|||||||
sink.flush().await
|
sink.flush().await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "hotpath", hotpath::measure(impl_type = "MpscTunnel"))]
|
|
||||||
async fn forward_one_round_with_timeout(
|
async fn forward_one_round_with_timeout(
|
||||||
rx: &mut Receiver<ZCPacket>,
|
rx: &mut Receiver<ZCPacket>,
|
||||||
sink: &mut Pin<Box<dyn ZCPacketSink>>,
|
sink: &mut Pin<Box<dyn ZCPacketSink>>,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use async_trait::async_trait;
|
|||||||
use futures::{Sink, SinkExt, Stream, StreamExt};
|
use futures::{Sink, SinkExt, Stream, StreamExt};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
|
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@@ -196,8 +196,7 @@ pub struct RingTunnelListener {
|
|||||||
|
|
||||||
impl RingTunnelListener {
|
impl RingTunnelListener {
|
||||||
pub fn new(key: url::Url) -> Self {
|
pub fn new(key: url::Url) -> Self {
|
||||||
let (conn_sender, conn_receiver) =
|
let (conn_sender, conn_receiver) = unbounded_channel();
|
||||||
hotpath::channel!(tokio::sync::mpsc::unbounded_channel());
|
|
||||||
RingTunnelListener {
|
RingTunnelListener {
|
||||||
listener_addr: key,
|
listener_addr: key,
|
||||||
conn_sender,
|
conn_sender,
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ use zerocopy::{AsBytes, FromBytes};
|
|||||||
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
net::UdpSocket,
|
net::UdpSocket,
|
||||||
sync::mpsc::{Receiver, Sender, UnboundedReceiver, UnboundedSender},
|
sync::mpsc::{
|
||||||
|
Receiver, Sender, UnboundedReceiver, UnboundedSender, channel, unbounded_channel,
|
||||||
|
},
|
||||||
task::JoinSet,
|
task::JoinSet,
|
||||||
};
|
};
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
@@ -673,9 +675,8 @@ pub struct UdpTunnelListener {
|
|||||||
|
|
||||||
impl UdpTunnelListener {
|
impl UdpTunnelListener {
|
||||||
pub fn new(addr: url::Url) -> Self {
|
pub fn new(addr: url::Url) -> Self {
|
||||||
let (close_event_send, close_event_recv) =
|
let (close_event_send, close_event_recv) = unbounded_channel();
|
||||||
hotpath::channel!(tokio::sync::mpsc::unbounded_channel());
|
let (conn_send, conn_recv) = channel(100);
|
||||||
let (conn_send, conn_recv) = hotpath::channel!(tokio::sync::mpsc::channel(100));
|
|
||||||
Self {
|
Self {
|
||||||
addr: addr.clone(),
|
addr: addr.clone(),
|
||||||
socket: None,
|
socket: None,
|
||||||
@@ -915,8 +916,7 @@ impl UdpTunnelConnector {
|
|||||||
"udp build tunnel for connector"
|
"udp build tunnel for connector"
|
||||||
);
|
);
|
||||||
|
|
||||||
let (close_event_sender, mut close_event_recv) =
|
let (close_event_sender, mut close_event_recv) = unbounded_channel();
|
||||||
hotpath::channel!(tokio::sync::mpsc::unbounded_channel());
|
|
||||||
|
|
||||||
let ring_recv = RingStream::new(ring_for_send_udp.clone());
|
let ring_recv = RingStream::new(ring_for_send_udp.clone());
|
||||||
let ring_sender = RingSink::new(ring_for_recv_udp.clone());
|
let ring_sender = RingSink::new(ring_for_recv_udp.clone());
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use hotpath::instant::Instant;
|
use quanta::Instant;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
FromUrl, IpVersion, Tunnel, TunnelError, TunnelInfo, TunnelListener, TunnelUrl, ZCPacketSink,
|
FromUrl, IpVersion, Tunnel, TunnelError, TunnelInfo, TunnelListener, TunnelUrl, ZCPacketSink,
|
||||||
@@ -37,7 +37,11 @@ use crossbeam::atomic::AtomicCell;
|
|||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use futures::{SinkExt, StreamExt, stream::FuturesUnordered};
|
use futures::{SinkExt, StreamExt, stream::FuturesUnordered};
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use tokio::{net::UdpSocket, sync::Mutex, task::JoinSet};
|
use tokio::{
|
||||||
|
net::UdpSocket,
|
||||||
|
sync::{Mutex, mpsc::unbounded_channel},
|
||||||
|
task::JoinSet,
|
||||||
|
};
|
||||||
|
|
||||||
const MAX_PACKET: usize = 2048;
|
const MAX_PACKET: usize = 2048;
|
||||||
|
|
||||||
@@ -470,7 +474,7 @@ pub struct WgTunnelListener {
|
|||||||
|
|
||||||
impl WgTunnelListener {
|
impl WgTunnelListener {
|
||||||
pub fn new(addr: url::Url, config: WgConfig) -> Self {
|
pub fn new(addr: url::Url, config: WgConfig) -> Self {
|
||||||
let (conn_send, conn_recv) = hotpath::channel!(tokio::sync::mpsc::unbounded_channel());
|
let (conn_send, conn_recv) = unbounded_channel();
|
||||||
WgTunnelListener {
|
WgTunnelListener {
|
||||||
addr,
|
addr,
|
||||||
config,
|
config,
|
||||||
|
|||||||
Reference in New Issue
Block a user