Repository navigation
feat(proxy-supervisor): Envoy thread-stall sampler to attribute the handoff stalls (#1093) - #1100
Merged
Merged
Conversation
…er a handoff stall is starvation, a block or a busy loop (#1093) The 2026-10-01 soak's three multi-second handoff stalls (w04 02:16 and 04:17, w05 05:41) cannot be attributed from today's data: Pyroscope is on-CPU only and showed nothing unusual, Envoy's worker watchdog counted misses only on w04/w05 but says neither when nor in what, and there is no per-node CPU/PSI series. Every 100 ms the supervisor now reads, for the main and wrk:* threads of each Envoy epoch it runs, /proc/<pid>/task/<tid>/{schedstat,stat,wchan} (no ptrace) and, per one-second window, classifies a thread as starved (runqueue wait), blocked (asleep outside ep_poll; wchan named) or busy (>=90% on a CPU) once it crosses --stall-threshold (200 ms, Envoy's watchdog miss bound). One "envoy thread stall" line per epoch per flagged window, with the node's busy/irq/softirq/steal shares, the hottest CPU's irq+softirq share and PSI cpu-some/irq-full for the same second, plus aether.supervisor.envoy_thread_stalls{class} seeded at 0. --stall-sample-interval=0 disables it. No chart change. Refs #1093 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 1, 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.
Refs #1093. This PR adds observability; it is not the fix. The data from the 2026-10-01 soak cannot say why the threads stalled. This PR records that the next time a stall happens.
What the soak data shows (read-only on talos-main)
1. The stall is node-local and is not caused by the handoff. A handoff only makes it worse.
duration_ms > 500, counted in 30 s buckets over the 8 h window:upstream_service_timeof about 1 s to127.0.0.1:8080. Example: w04 at 06:27:07, 40 lines at 0.5–1 s.2. The new epoch's Envoy workers are the threads that stall.
envoy_workers_watchdog_miss_total(Envoy counts a miss when a worker goes ≥ 200 ms without a loop iteration) moved only on w04 and w05 during the 8 h. It never moved on w01–w03.envoy_server_worker_{0,3}_watchdog_miss_totalof epoch 119 rose between 02:16:45 and 02:16:50. That is exactly the stall window.5c483b89was received by the w04 source at 46.618. It reached its w02 destination at 49.099 and was served there in 6 ms. So 2.5 s was lost on w04.3. The stall is not visible as CPU.
process_cpu) over the stall shows:Ruled out:
initial fetch timed out, and the drain started after the child's workers.child_silent0, noforwarding queue is full.lds: add/update listenerlines in any of the three windows are the successor's initial load, beforestarting workers.What this PR adds
A thread-stall sampler in the proxy supervisor:
agent/internal/proxy/hotrestart/{stallsampler,procstat}.go.--stall-sample-interval; 0 disables it)./proc/<envoy>/task/<tid>/{schedstat,stat,wchan}for the main thread and thewrk:*threads of every epoch the supervisor runs. It uses no ptrace.starved: waiting in the runqueue;blocked: asleep anywhere other thanep_poll, with the wchan named;busy: on a CPU for ≥ 90% of the window.--stall-threshold, default 200 ms, which is Envoy's own watchdog miss bound.envoy thread stallline per epoch per flagged window. The line carries the node's figures for the same second: busy, irq, softirq and steal shares; the irq+softirq share of the hottest CPU; and PSI cpu-some and irq-full.aether.supervisor.envoy_thread_stalls{class}, seeded at 0.Proof
stallsampler_test.go) run against a fake procfs. They cover:windowMsreports the actual span;/proc/statand PSI lines;/procread.bazel test --config=race //agent/internal/proxy/hotrestart:all //agent/internal/supervisorcmd:all,//agent/cmd/proxy-supervisor:deps_test,make gazelle/make format, and lint withfail_on_violation(gocognit ≤ 15 holds).aether-1093, chart from this branch, since deleted):ep_poll, as the classifier assumes.cpu.maxthrottle of the proxy container logged every thread as starved, with the node quiet:blockedandbusyclasses. They are covered only by the unit tests.Talos gate for the main session after deploy
envoy thread-stall sampler runningmust appear on 5/5 nodes. Theaether_supervisor_envoy_thread_stalls_totalseries must exist on 5/5 nodes (seeded at 0).envoy thread stalllines from fork−5 s to parent exit+5 s on that node.starvedwith highnodePSICPUSomeMs: node CPU contention. Find from Pyroscope, node-wide, which processes took the CPU. Fix with proxy CPU priority or QoS, or by spreading the handoff burst.blockedwith a wchan: the stall is in that kernel path or lock. Fix it there.busy: use Pyroscope on that worker in that second to find the callback.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr