mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-06 04:29:52 +00:00
perf(data-plane): reduce per-packet synchronization overhead (#2453)
* perf(stats): avoid per-update clock reads Perf profiles show quanta::get_now consuming 2.9-4.3% of data-plane CPU because every counter update refreshes a high-resolution timestamp. Track metric activity with the existing 60-second cleanup cadence instead. Relaxed 32-bit epochs preserve the three-minute retention window, support 32-bit targets, and remove repeated clock reads from packet processing. * perf(data-plane): reduce per-packet synchronization Perf profiles showed per-packet config Arc cloning, bounded-channel permit futures, duplicate peer lookups, and default connection UUID lookups consuming CPU in both TCP and UDP data paths. Borrow stable config snapshots, use nonblocking channel fast paths with the existing backpressure fallback, reuse direct peer lookups, and cache the selected connection while preserving close and reselection behavior. Add focused tests for channel backpressure and cached connection invalidation. * fix(peer): serialize default connection cache updates The profile-guided default connection cache could republish a connection after the close task removed it, leaving a stale cache while another connection remained live. Serialize only cache-miss selection/publication and connection removal. The per-packet cache-hit path remains lock-free, while close and selection can no longer race to resurrect a removed connection.
This commit is contained in:
@@ -763,7 +763,8 @@ impl PeerContext for CorePeerContext {
|
||||
}
|
||||
|
||||
fn packet_policy(&self) -> PeerPacketPolicy {
|
||||
PeerPacketPolicy::from_flags(&self.snapshot().flags)
|
||||
self.config
|
||||
.with_snapshot(|snapshot| PeerPacketPolicy::from_flags(&snapshot.peer.flags))
|
||||
}
|
||||
|
||||
fn host_routing_policy(&self) -> HostRoutingPolicy {
|
||||
@@ -792,13 +793,16 @@ impl PeerContext for CorePeerContext {
|
||||
}
|
||||
|
||||
fn ipv4(&self) -> Option<Ipv4Inet> {
|
||||
self.snapshot()
|
||||
.runtime
|
||||
.core
|
||||
.routes
|
||||
.ipv4
|
||||
.as_ref()
|
||||
.and_then(config_ipv4)
|
||||
self.config.with_snapshot(|snapshot| {
|
||||
snapshot
|
||||
.peer
|
||||
.runtime
|
||||
.core
|
||||
.routes
|
||||
.ipv4
|
||||
.as_ref()
|
||||
.and_then(config_ipv4)
|
||||
})
|
||||
}
|
||||
|
||||
fn ipv6(&self) -> Option<Ipv6Inet> {
|
||||
|
||||
Reference in New Issue
Block a user