perf: make collector poll interval configurable, default 1s/5s - #43
Open
auroracapital wants to merge 1 commit into
Open
perf: make collector poll interval configurable, default 1s/5s#43auroracapital wants to merge 1 commit into
auroracapital wants to merge 1 commit into
Conversation
The collector woke 4 times a second and re-collected every second. On a busy
tmux server that cost about 7% of a CPU core continuously: 33 minutes of CPU
over 7.4 hours of uptime, just to draw the status bar.
Default to a 1s tick with collection every 5th wakeup, and expose both as tmux
options for anyone who wants the old responsiveness back:
set -g @agent-tick-seconds 0.25
set -g @agent-ticks-per-collect 4
Measured on macOS 27, M5 Max, 15 windows across 2 sessions: 7.5% of a core
before, 3.0% after, with no visible change to the sidebar.
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.
What
The sidebar collector woke 4 times a second and re-collected every second. This makes both intervals configurable and lowers the defaults to a 1s tick with collection every 5th wakeup.
Why
I noticed my Mac sitting at a high load average and traced a chunk of it here.
sidebar-collector.shhad used 33 minutes of CPU over 7.4 hours of uptime, about 7% of a core continuously, to draw a status bar.The loop wakes at
sleep 0.25mainly to animate the spinner, and runs the real collection every 4th tick. The spinner is the only thing that needs sub-second timing, and at 1s it still animates fine.Numbers
Measured on macOS 27, M5 Max, 15 windows across 2 sessions:
Roughly 60% cheaper. I left it running for 12 minutes after the change and the sidebar updates the same as far as I can tell.
Config
Both values are tmux options, matching the existing
@agent-*style. To get the old behaviour back:Defaults are
1and5. README updated.Notes
The defaults are a judgement call, so if you would rather have 0.5s/4 or keep the current values and just expose the options, happy to change it. The configurability is the part I actually care about.