Timeout Select errors by up to 1s to avoid callers pinning CPU and filling /var/log#1231
Open
mdhoff-ms wants to merge 4 commits into
Open
Timeout Select errors by up to 1s to avoid callers pinning CPU and filling /var/log#1231mdhoff-ms wants to merge 4 commits into
mdhoff-ms wants to merge 4 commits into
Conversation
Signed-off-by: Matt Hoffman <matthoffman@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR updates the core swss::Select event loop implementation to throttle repeated Select::ERROR returns, reducing CPU pinning and runaway log growth when underlying selectables (e.g., Redis-backed ones) repeatedly fail to readData().
Changes:
- Adds a 1-second backoff when
Select::select()returnsSelect::ERROR. - Refactors the early-return logic in
Select::select()to make return conditions more explicit. - Adds
<chrono>/<thread>includes to support the new throttling sleep.
Signed-off-by: Matt Hoffman <matthoffman@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Signed-off-by: Matt Hoffman <matthoffman@microsoft.com>
mdhoff-ms
force-pushed
the
dev/matthoffman/throttle-redis-select
branch
from
July 22, 2026 06:20
111179b to
d538530
Compare
Author
|
maybe a good idea is to sleep only for the timeout that's passed in, then add a separate backoff (equal to 1s) to the actual logging statement. This would preserve the exact contract the caller is expecting while also mitigating the log spam. |
anti-spin timeout capped at 1s. Additional 1s rate limiting for logging. Signed-off-by: Matt Hoffman <matthoffman@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
mdhoff-ms
marked this pull request as ready for review
July 23, 2026 23:55
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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.
I have noticed two instances of filled /var/log on DUTs with many repeated lines:
these repeat immediately, leading to /var/log partition being filled very quickly. It seems that the error case of
common/select.cpp(e.g. if redis is down) returns immediately, leading to callers who call in loops spinning indefinitely and filling the log partition.To fix this I propose the following change:
On the
Select::ERRORpath, we should enforce the timeout requested by the caller (often 1ms, 100ms, etc) up to a cap of 1 second, to avoid pinning the CPU in a hot loop. Additionally the readData error log should be rate limited to once per second, to avoid flooding /var/log/syslog and filling the partition.