Skip to content

Stop the idle loop in Main from polling every millisecond - #20

Merged
carlbennett merged 2 commits into
BNETDocs:developfrom
wjlafrance:fix/idle-loop-cpu
Oct 9, 2026
Merged

carlbennett merged 2 commits into
BNETDocs:developfrom
wjlafrance:fix/idle-loop-cpu

Conversation

@wjlafrance

Copy link
Copy Markdown
Collaborator

The loop that waits for Program.Exit used Task.Delay(1) followed by Task.Yield(), which woke the thread pool about a thousand times a second. An idle atlasd (no clients connected) used about 32% of a core on macOS/.NET 10; with a 250ms delay it uses about 1.3%. Shutdown reacts within 250ms.

wjlafrance and others added 2 commits October 8, 2026 21:47
The loop that waits for Program.Exit used Task.Delay(1) followed by Task.Yield(),
which woke the thread pool about a thousand times a second. An idle atlasd (no
clients connected) used about 32% of a core on macOS/.NET 10; with a 250ms delay
it uses about 1.3%. Shutdown reacts within 250ms.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
NullTimer sends SID_NULL every 60 seconds and PingTimer sends SID_PING every 180
seconds, but both fired every 100ms, and PingTimer reads a setting and allocates a
message and a Random on every tick. A one second period is still far finer than the
intervals they enforce. Idle atlasd (no clients, 250ms idle loop) went from about
1.5% of a core to about 0.5%.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@carlbennett carlbennett self-assigned this Oct 9, 2026
@carlbennett carlbennett added the enhancement New feature or request label Oct 9, 2026
@carlbennett
carlbennett merged commit 147c2e0 into BNETDocs:develop Oct 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants