mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 01:25:37 +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,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use hotpath::instant::Instant;
|
||||
use rand::{Rng, thread_rng};
|
||||
use tokio::{
|
||||
sync::broadcast,
|
||||
@@ -177,7 +178,7 @@ impl PeerConnPinger {
|
||||
sink.send(req).await?;
|
||||
control_metrics.record_tx(req_len);
|
||||
|
||||
let now = std::time::Instant::now();
|
||||
let now = Instant::now();
|
||||
// wait until we get a pong packet in ctrl_resp_receiver
|
||||
let resp = timeout(Duration::from_secs(2), async {
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user