Repository navigation
Re-check controller connections only when they changed (CHOO-3667) - #1255
Closed
abeldantas wants to merge 2 commits into
Closed
abeldantas wants to merge 2 commits into
abeldantas wants to merge 2 commits into
Conversation
Every 30 seconds every process read the connection row of every controller that ever opened one, revoked ones included, with their status and platform JSON, and for each controller another process held, the rooms of all its agents. At 10,000 agents behind 500 controllers that was a one-second query and about a second of CPU decoding JSON per process every 30 seconds, and about ten room queries a second. The re-check now first compares a fingerprint of the connection columns it acts on, and of the processes holding a lease, with the last full read, and reads only the connection columns when it reads at all. The rooms of a controller's agents are kept by the membership signals and MessageRouter.recheck_agent_rooms meanwhile.
abeldantas
requested review from
agent-runner353,
amaudruz,
christian-mcdermott,
lbangalosbt,
massimo-sandboxaq,
niall-sandboxaq,
petr-sandbox,
raullopez-sandbox and
simonflk-sb
as code owners
November 1, 2026 03:01
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A moderate issue remains where newly bound agents on remote controllers may miss room membership refreshes and stay absent from message delivery until a later change or restart.
1 open issue
What changed in this PR
This pull request optimizes periodic controller reconciliation by checking connection and lease fingerprints before performing full reads, while retaining full startup and reconnect synchronization. It also adds targeted regression coverage and changelog documentation.
Changes:
- Added narrow controller connection projections and fingerprint queries.
- Skipped unchanged periodic connection and room reads.
- Preserved rechecks for connection, lease, startup, and reconnect changes.
- Added tests for unchanged, disconnected, and expired-lease scenarios.
- Documented the optimization in the changelog.
- Identified a moderate issue where newly bound agents on remotely held controllers may not receive an initial room refresh.
| File | Summary |
|---|---|
core/tests/switch_core/management/test_controller_signals.py |
Adds coverage for skipped reads and rechecks triggered by connection or lease changes. |
core/switch_core/management/signals.py |
Uses connection and lease fingerprints to avoid unnecessary periodic reads; newly bound agents on remote controllers require room-refresh handling. |
core/switch_core/db/stores/agent_controller_store.py |
Adds narrow connection-column queries and matching fingerprint calculation. |
CHANGELOG.md |
Documents the reduced controller reconciliation workload. |
Review effort: Lite
Comment on lines
+325
to
+326
| seen |= self._connections_seen.get(tenant_id, set()) | ||
| continue |
Collaborator
Author
|
Combined into #1307 with the other scaling PRs. |
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.

Every 30 seconds every process read the connection row of every controller that ever opened one, revoked ones included, with its status and platform JSON, and for each controller another process held, the rooms of all its agents. In a load test with 10,000 agents behind 500 controllers on 12 processes, that was a one-second query on each process every 30 seconds, decoding that JSON was about a quarter of the processes' CPU while nothing else happened, and the room reads ran about ten times a second on each process at 3 ms each.
In this PR the re-check (
ControllerSignals.recheck):AgentControllerStore.connections_fingerprint)AgentControllerStore.connections), where it read whole rowsThe rooms of a controller's agents stay current meanwhile through the membership signals and
MessageRouter.recheck_agent_rooms, which re-reads them every 30 seconds. Startup and a reconnect still read everything.Stack (merge order)