engine: park the hot loop while every transport is down (ibx#399) - #401
Open
userFRM wants to merge 1 commit into
Open
engine: park the hot loop while every transport is down (ibx#399)#401userFRM wants to merge 1 commit into
userFRM wants to merge 1 commit into
Conversation
The loop busy-polls three sockets and never yields. That is the point while a session is up: a poll that finds a tick returns it without a syscall in the way, and `core_id` exists so the spin can own a core. With every transport down there is nothing to poll. Each pass runs the same three polls, gets nothing from any of them, and starts again. Measured here at roughly 925,000 iterations a second, which is one core at 100% for as long as the disconnect lasts. On a laptop that is the fans and the battery, which is how it gets noticed. Parking one millisecond in that state and only that state leaves the connected path untouched. Nothing is waiting on the loop either: reconnects are already scheduled on a backoff measured in seconds, and shutdown is read once per pass. The report this comes from attributes the CPU to the reconnect scheduler warning in a tight retry. The timestamps in it show those warnings two minutes apart, which is the 60-second re-check working as intended. The spin is the loop itself and is present whether or not credentials are cached. `a_loop_with_every_transport_down_does_not_spin` counts iterations rather than CPU time, which is what separates a parked loop from a spinning one on any machine. Removing the sleep takes it from 60 to 55,554 in the same window. Closes deepentropy#399. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Summary
core_idexists so the spin can own a core.On the reported cause
The report puts the CPU on the reconnect scheduler retrying in a tight loop. The timestamps in its own log are two minutes apart:
That is the 60-second re-check in
maybe_spawn_ccp_reconnectdoing its job. The spin is the loop body itself, and it is there whether or not credentials are cached — a connected engine spins too, which is intended, and a disconnected one spins for nothing, which is not.Closes #399.
Test plan
cargo test --lib— 803 pass. The twoconfig::expiry_testsfailures are pre-existing on main and identical on a pristine checkout of 9367845.a_loop_with_every_transport_down_does_not_spindrivesrun()with all three transports marked down, shuts it down after 60 ms and asserts the iteration count. Counting iterations rather than CPU time is what separates a parked loop from a spinning one on any machine.