byobu-status is very CPU-intensive on Mac OS
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
byobu |
New
|
Undecided
|
Unassigned |
Bug Description
I noticed that having a terminal open with byobu running was killing my battery life, and eventually I tracked it down to byobu-status taking a ridiculous amount of time to run, almost half a second. Given that the command runs twice per second (tmux_left & tmux_right), this basically means that one CPU core is pegged at 100% just running byobu-status constantly. As a result, my Macbook goes from around 5 watts to over 20 watts, sometimes over 30 watts, and battery life is cut accordingly.
Disabling the status bar has no effect because the offending line is
. "${BYOBU_
which happens right before the script exits if status is disabled. Here's an example (with status.disable present):
$ for x in `seq 10`; do time byobu-status; done
byobu-status 0.20s user 0.20s system 80% cpu 0.495 total
byobu-status 0.22s user 0.22s system 82% cpu 0.533 total
byobu-status 0.19s user 0.18s system 81% cpu 0.456 total
byobu-status 0.22s user 0.22s system 80% cpu 0.553 total
byobu-status 0.19s user 0.19s system 82% cpu 0.459 total
byobu-status 0.22s user 0.22s system 82% cpu 0.533 total
byobu-status 0.19s user 0.18s system 81% cpu 0.455 total
byobu-status 0.22s user 0.22s system 82% cpu 0.532 total
byobu-status 0.19s user 0.18s system 82% cpu 0.444 total
byobu-status 0.22s user 0.22s system 80% cpu 0.554 total
Running the same on my linux server tells me that byobu-status runs in about 0.01 seconds there, so this seems to be specific to Mac OS. My Mac OS is 10.14.5, but based on how long I've been having battery life issues, this problem has existed on several previous Mac OS versions as well.
I suppose I should mention that byobu is installed via homebrew.
Also, as would be expected, adding "exit 0" as the first line of byobu-status fixes the CPU usage, and obviously gets rid of all status indicators (except date and time, which I guess are handled separately).