perf: move per-packet datapath logging to DEBUG - #30
Open
kedimuzafer wants to merge 1 commit into
Open
Conversation
Several log statements on the WireGuard/DISCO datapath run at INFO, so they
are emitted for every packet on a default build. Two are unconditional
printf() calls. At 115200 baud each of these lines blocks the task that
writes it for roughly 6 ms, and they sit in the receive path itself.
Measured on an ESP32-S3 acting as a Tailscale SOCKS5 proxy: with these at
INFO the node could not sustain more than ~20 packets/s before the lwIP UDP
mailbox backed up behind the UART and TCP through the tunnel collapsed. ICMP
to the node stopped answering for the duration of any transfer.
Demoted to ESP_LOGD / WG_DEBUG, so they compile out at the default log level
and are still available by raising it:
ml_net_io.c "UDP RX: ..." - once per received packet
wireguardif.c "[WG_RX] type=..." - once per received packet, printf
ml_wg_mgr.c DISCO RX/PING/PONG, WG RX/TX, the WG INIT hex dump,
wireguardif_periodic and disco_periodic_probes timings
ml_derp.c DERP RecvPacket/SendPacket/PeerGone, HEARTBEAT
Also drops the [TAI64N] uptime printf from wireguard_tai64n_now(): it is
rate-limited to every 5 s but sits on the handshake path and logs nothing
actionable.
No behaviour changes beyond log verbosity.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bqLmUG7wJ7p9ya2Vp4A9J
This was referenced Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A handful of log statements on the WireGuard/DISCO datapath are at
ESP_LOGI, and two are plainprintf(). On a default build they therefore fire once per packet.At 115200 baud a ~70-character line takes ~6 ms to write, and the UART write blocks the task that issues it.
ml_net_io.c'sUDP RX:line is emitted from the socket receive task before the packet is even queued, so the cost lands directly in the receive path.Measurement
ESP32-S3 (8 MB PSRAM) running MicroLink as a Tailscale SOCKS5 proxy, peer on the same LAN, direct path:
Before the change, any TCP transfer larger than a few tens of KB through the tunnel stalled, and the node stopped answering ICMP for the duration — the UART was holding the receive task while the lwIP UDP mailbox (
CONFIG_LWIP_UDP_RECVMBOX_SIZE, 6 by default) overflowed behind it.Change
Demoted to
ESP_LOGD/WG_DEBUGso they compile out at the default log level and remain available by raising it:ml_net_io.c—UDP RX: ..., once per received packetwireguardif.c—[WG_RX] type=..., once per received packet, a rawprintfml_wg_mgr.c—DISCO RX/PING/PONG,WG RX/WG UDP TX, theWG INIThex dump, and thewireguardif_periodic/disco_periodic_probestiming linesml_derp.c—DERP RecvPacket/SendPacket/PeerGone,HEARTBEATAlso removes the
[TAI64N]uptimeprintfinwireguard_tai64n_now(). It is rate-limited to every 5 s, but it sits on the handshake path and reports nothing actionable.Nothing changes except log verbosity. Everything demoted is still reachable with
esp_log_level_set()or a higherCONFIG_LOG_MAXIMUM_LEVEL.