mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 09:35:41 +00:00
perf(core): use quanta::Instant for hot-path timing (#2384)
Replace std::time::Instant with quanta::Instant on per-packet, per-RPC, and per-session paths. TSC-based, ~5ns vs ~25ns per now() call. Reuses the existing `extern crate self as hotpath` alias so `use hotpath::instant::Instant;` resolves to the same quanta type with or without the hotpath feature. Leaves tokio::time::Instant and smoltcp::time::Instant untouched.
This commit is contained in:
@@ -6,6 +6,8 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use hotpath::instant::Instant;
|
||||
|
||||
use super::{
|
||||
FromUrl, IpVersion, Tunnel, TunnelError, TunnelInfo, TunnelListener, TunnelUrl, ZCPacketSink,
|
||||
ZCPacketStream,
|
||||
@@ -346,7 +348,7 @@ struct WgPeer {
|
||||
data: Option<WgPeerData>,
|
||||
tasks: JoinSet<()>,
|
||||
|
||||
access_time: AtomicCell<std::time::Instant>,
|
||||
access_time: AtomicCell<Instant>,
|
||||
}
|
||||
|
||||
impl WgPeer {
|
||||
@@ -369,7 +371,7 @@ impl WgPeer {
|
||||
data: None,
|
||||
tasks: JoinSet::new(),
|
||||
|
||||
access_time: AtomicCell::new(std::time::Instant::now()),
|
||||
access_time: AtomicCell::new(Instant::now()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +387,7 @@ impl WgPeer {
|
||||
}
|
||||
|
||||
async fn handle_packet_from_peer(&self, packet: &[u8]) {
|
||||
self.access_time.store(std::time::Instant::now());
|
||||
self.access_time.store(Instant::now());
|
||||
tracing::trace!("Received {} bytes from peer", packet.len());
|
||||
let data = self.data.as_ref().unwrap();
|
||||
// TODO: improve this
|
||||
|
||||
Reference in New Issue
Block a user