Skip to content

feat: PR3A — Instruments signposts for tunnel lifecycle profiling#8

Open
mrmidi wants to merge 1 commit into
pr3/binary-diagnosticsfrom
pr3a/signposts
Open

feat: PR3A — Instruments signposts for tunnel lifecycle profiling#8
mrmidi wants to merge 1 commit into
pr3/binary-diagnosticsfrom
pr3a/signposts

Conversation

@mrmidi

@mrmidi mrmidi commented Jul 21, 2026

Copy link
Copy Markdown
Owner

PR3A — Instruments Signposts

Base: pr3/binary-diagnostics · 3 files, +144/-1

Scope

Deliberately small: no persistence, no JSON changes, no state-machine changes, no per-packet instrumentation.

Signposts

Intervals (begin/end around async operations):

Signpost Begin End
TunnelStartup startTunnel entered finishStart called
BridgeLifetime bridge created bridge stopped (per generation)
NativeTeardown bridge detached final status captured
TunnelShutdown stopTunnel entered completionHandler called
ReconnectDelay reconnect scheduled fired/cancelled

Point events (instantaneous):

TransportConnected, TransportDisconnected, NetworkPathChanged, MemoryWarning, InvariantViolation, PacketReadLoopStarted, PacketReadLoopStopped

Build config

  • FPTN_SIGNPOSTS added to Debug and Measurement configs
  • No signposts in Release (production)
  • import OSLog guarded by #if FPTN_SIGNPOSTS

State storage

Single active bridge signpost (PR2 guarantees single exposed bridge):

#if FPTN_SIGNPOSTS
private var startupSignpost: OSSignpostIntervalState?
private var bridgeSignpost: (generation: Int, id: OSSignpostID, state: OSSignpostIntervalState)?
private var teardownSignpost: ...
private var shutdownSignpost: OSSignpostIntervalState?
private var reconnectSignpost: ...
#endif

Acceptance test

Record Allocations + VM Tracker in Instruments and verify:

TunnelStartup
BridgeLifetime generation 1
NativeTeardown generation 1
ReconnectDelay
BridgeLifetime generation 2
TunnelShutdown
NativeTeardown generation 2

Verification

  • Xcode Debug build: succeeded
  • Tests: 27/27 passed

Stack

PR2   Provider integration
PR3   Binary diagnostics core     (base)
PR3A  Instruments signposts       ← this PR
PR4   Shared contracts
PR5   Packet-copy reduction

TunnelSignposts (FptnVPNTunnel/Diagnostics/TunnelSignposts.swift):
- OSSignposter with subsystem net.mrmidi.FptnVPN.FptnVPNTunnel
- Compiled only when FPTN_SIGNPOSTS is defined (Debug + Measurement)

Intervals:
- TunnelStartup: startTunnel → finishStart
- BridgeLifetime: bridge created → bridge stopped (per generation)
- NativeTeardown: bridge detached → final status captured
- TunnelShutdown: stopTunnel → completionHandler
- ReconnectDelay: reconnect scheduled → fired/cancelled

Point events:
- TransportConnected, TransportDisconnected
- NetworkPathChanged, MemoryWarning, InvariantViolation
- PacketReadLoopStarted, PacketReadLoopStopped

Build config:
- FPTN_SIGNPOSTS added to Debug and Measurement configs
- No signposts in Release (production)

No persistence, no JSON, no per-packet instrumentation.
Numeric metadata only, no interpolated strings.

Tests: 27/27 passed. Debug build succeeded.
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.

1 participant