Skip to content

perf: make collector poll interval configurable, default 1s/5s - #43

Open
auroracapital wants to merge 1 commit into
samleeney:mainfrom
auroracapital:perf/configurable-poll-interval
Open

perf: make collector poll interval configurable, default 1s/5s#43
auroracapital wants to merge 1 commit into
samleeney:mainfrom
auroracapital:perf/configurable-poll-interval

Conversation

@auroracapital

Copy link
Copy Markdown

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.sh had 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.25 mainly 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:

CPU
before (0.25s / 1s) 7.5% of a core
after (1s / 5s) 3.0% of a core

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:

set -g @agent-tick-seconds 0.25
set -g @agent-ticks-per-collect 4

Defaults are 1 and 5. 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants