Skip to content

feat: restore optional hotpath profiling#2402

Draft
fanyang89 wants to merge 4 commits into
mainfrom
feat/hotpath-profiling
Draft

feat: restore optional hotpath profiling#2402
fanyang89 wants to merge 4 commits into
mainfrom
feat/hotpath-profiling

Conversation

@fanyang89

Copy link
Copy Markdown
Member

Summary

  • restore optional hotpath-rs 0.19 support behind the hotpath feature, keeping default builds dependency-free via local no-op macros
  • instrument hot-path locks, channels, and functions with hotpath wrap/mutex/rw_lock/channel/measure coverage
  • initialize the profiler from easytier-core only when hotpath is enabled, with hotpath-alloc rejected alongside jemalloc or mimalloc

Notes

  • parking_lot::Mutex remains unwrapped because hotpath 0.19 only exposes parking_lot RwLock wrappers
  • peer_ospf_route parking_lot RwLock remains unwrapped because it uses upgradable_read guards that hotpath does not expose; route lookup still has function-level measure coverage
  • quic RwPool Debug is manual because hotpath wrapped RwLock does not implement Debug

Benchmark

Short local Criterion run, ring tunnel, 1400B packets, inflight 64, 4 workers:

case off hotpath on delta
ring 5.01 us / 266 MiB/s 5.35 us / 250 MiB/s +6.3% time
ring-saturate 4.99 us / 268 MiB/s 5.43 us / 246 MiB/s +9.3% time

This confirms default/off stays baseline while enabled profiling carries the expected measurement overhead.

Validation

  • cargo check -p easytier --all-targets
  • cargo check -p easytier --features hotpath --all-targets
  • cargo build -p easytier --features hotpath,hotpath-cpu --bin easytier-core
  • cargo clippy -p easytier
  • cargo clippy -p easytier --features hotpath
  • cargo check -p easytier --features hotpath-alloc,jemalloc confirms compile_error
  • cargo check -p easytier --features hotpath,hotpath-alloc --lib
  • cargo test -p easytier --lib -- --skip tests::
  • cargo test -p easytier --lib secure_datagram

Full integration tests requiring brctl/network namespaces were not runnable in this environment.

fanyang89 and others added 4 commits July 2, 2026 21:19
Re-enable the hotpath profiler as an optional dependency gated behind the
 feature (default off). In off builds the crate stays out of the
dependency graph entirely:  plus a local
 module provide no-op // macros so
call sites compile unchanged. Also add a  guarding the
mutual exclusivity of  with the / global
allocators.
Wrap the per-packet locks and channels behind hotpath's drop-in wrappers
() so lock contention and
channel flow become visible when the  feature is on, while staying
zero-cost in default builds via cfg-gated dual imports and the no-op
// macros. Annotate the hottest send/recv,
encrypt/decrypt, and forward functions with .

Coverage: peer_conn/peer_manager/peer_map/peer/peer_session/secure_datagram
locks, mpsc/ring/udp/wireguard/fake_tcp channels, quic connection pool,
relay/foreign send paths, and OSPF route lookup (function-level only; its
parking_lot upgradable guards have no hotpath wrapper).

Debug impls that formatted lock fields are updated to dereference the inner
value, and quic's RwPool switches to a manual Debug that skips the locks.
Gate the binary entry point with hotpath::main when the feature is enabled,
except when hotpath-alloc is combined with a custom global allocator
(jemalloc/mimalloc), which is already rejected at compile time in lib.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants