question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

excessive CPU usage compared to alternative

See original GitHub issue

Bug Report

Description

Affected module: unknown, possibly all Version used: 2.1.5+dfsg2-1 (as packaged in Debian)

Bumblebee-status steadily uses between 5 and 10% of available CPU time on my workstation.

How to reproduce

Itโ€™s hard to describe exactly what leads to that problem. I have a handful of modules here, which are best described by just attaching this config file here.

config.txt

hereโ€™s what it looks like in btop:

โ•ญโ”€โ”ยนcpuโ”Œโ”€โ”€โ”menuโ”Œโ”preset *โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”17:55:08โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”BATโ–ฒ 83% โ– โ– โ– โ– โ– โ– โ– โ– โ– โ–  โ”Œโ”- 1000ms +โ”Œโ”€โ•ฎ
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                            โข                                                โ•ญโ”€โ”i7-7500Uโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”700 MHzโ”Œโ•ฎโ”‚
โ”‚                                                                                                            โขธ           โฃฆโฃคโฃ โฃคโฃค     โก€โก€โก€   โก„     โก†โข             โ”‚CPU โ– โ– โ– โ– โ– โ– โ– โ– โ– โ–    5% โฃ€โฃ€โฃ€โฃ€โฃ€  43ยฐCโ”‚โ”‚
โ”‚                                                                                                            โขธ           โฃฟโฃฟโฃฟโฃฟโฃฟโก†โฃผโก„ โฃดโฃทโฃฟโก‡โขฐโขธโฃถโฃงโฃฆโก€  โข€โฃงโขธ  โก€         โ”‚C0  โฃ€โฃ€โฃ€โข€โฃ€โฃ€โฃ€โฃ€โฃ€โก€   3% โฃ€โฃ€โฃ€โฃ€โฃ€  42ยฐCโ”‚โ”‚
โ”‚                                                                                                            โขธโฃฐโฃฆโฃ โฃคโฃคโฃ„โฃ€โฃคโฃคโฃ„โฃธโฃฟโฃฟโฃฟโฃฟโฃฟโฃทโฃฟโฃงโฃถโฃฟโฃฟโฃฟโฃทโฃฟโฃฟโฃฟโฃฟโฃฟโฃ‡โฃคโฃคโฃผโฃฟโฃฟโฃงโฃดโฃงโฃ„โฃ โฃฆโฃ„โฃคโฃคโฃคโฃคโฃคโ”‚C1  โก€โก€โข€โข€โฃ€โฃ€โก€โฃ€โฃ€โก€   4% โฃ€โฃ€โฃ€โฃ€โฃ€  42ยฐCโ”‚โ”‚
โ”‚                                                                                                            โขธโ นโ Ÿโ ™โ ›โ ›โ ‹โ ‰โ ›โ ›โ ‹โขนโฃฟโฃฟโฃฟโฃฟโฃฟโกฟโฃฟโกŸโ ฟโฃฟโฃฟโฃฟโกฟโฃฟโฃฟโฃฟโฃฟโฃฟโกโ ›โ ›โขปโฃฟโฃฟโกŸโ ›โกŸโ ‹โ ™โ ›โ ‹โ ›โ ›โ ›โ ›โ ›โ”‚C2  โฃ€โก€โข€โฃ€โฃ€โข€โฃ€โฃ€โข€โข€   5% โฃ€โฃ€โฃ€โฃ€โฃ€  42ยฐCโ”‚โ”‚
โ”‚                                                                                                            โขธ           โฃฟโฃฟโฃฟโฃฟโฃฟโ ƒโ นโ  โ ™โกŸโกฟโก‡โ ˜โ ธโ ›โกโ Ÿ   โ ˆโกŸโขธ  โ          โ”‚C3  โฃ€โก€โข€โฃ€โก€โฃ€โฃ€โก€โฃ€โฃ€   4% โฃ€โฃ€โฃ€โฃ€โฃ€  42ยฐCโ”‚โ”‚
โ”‚                                                                                                            โขธ           โ ƒโ โ ˆโ ˆโ            โ      โ ƒ             โ”‚Load AVG:   0.43   1.80   1.10 โ”‚โ”‚
โ”‚                                                                                                            โ ˆ                                               โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏโ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚ up 00:06:49                                                                                                                                                                                 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€โ”5243โ”Œโ”bumblebee-statuโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”terminateโ”Œโ”killโ”Œโ”signalsโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”hide โ†ตโ”Œโ”€โ•ฎ
โ”‚6.5%                                                                 โ”‚     Status:      Elapsed:        IO/R:         IO/W:        Parent:        User:       Threads:        Nice:          โ”‚
โ”‚                                                                     โ”‚    Sleeping      00:05:52      7.99 MiB      16.0 KiB         sh          anarcat          4             0            โ”‚
โ”‚C                                                                    โ”‚                                                                                                                       โ”‚
โ”‚P                                                                    โ”‚                          Memory: 0.1% โฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃคโฃค 22.5 MiB                               โ”‚
โ”‚U                                                                    โ”‚ C                                                                                                                     โ”‚
โ”‚                                                                     โ”‚ M                          /usr/bin/python3 /usr/bin/bumblebee-status --iconset awesome-fonts                         โ”‚
โ”‚                       โข€โฃ โฃคโฃคโฃคโฃ โฃงโฃคโฃคโฃ โฃคโฃคโฃ โฃคโฃ โฃคโฃคโฃคโฃ€โฃคโฃฆโฃงโฃ โฃฆโฃคโฃ โฃฆโฃคโฃคโฃ โฃคโฃคโฃฆโฃคโฃคโฃคโฃคโฃคโฃ โฃ โฃ†โฃคโฃ„โฃคโฃคโฃคโ”‚ D                                                                                                                     โ”‚
โ”œโ”€โ”โดprocโ”Œโ”f bumble delโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”per-coreโ”Œโ”reverseโ”Œโ”treeโ”Œโ”< cpu lazy >โ”Œโ”€โ”ค
โ”‚    Pid: Program:         Command:                                                                                                                     Threads: User:       MemB       Cpu%  โ”‚
โ”‚    5243 bumblebee-statu  /usr/bin/python3 /usr/bin/bumblebee-status --iconset awesome-fonts                                                                  4 anarcat      23M โฃ€โฃ€โฃ€โฃ€โฃ€  6.5  โ”‚
โ”‚    5233 sh               /bin/sh -c bumblebee-status --iconset awesome-fonts                                                                                 1 anarcat     524K โฃ€โฃ€โฃ€โฃ€โฃ€  0.0  โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ”‚                                                                                                                                                                                             โ”‚
โ•ฐโ”˜โ†‘ select โ†“โ””โ”˜info โ†ตโ””โ”˜terminateโ””โ”˜killโ””โ”˜signalsโ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜0/2โ””โ•ฏ

โ€ฆ well that doesnโ€™t look quite alright, so hereโ€™s a screenshot.

snap-20220621T175547

anyways. point is itโ€™s taking up a lot of CPU. right now it has been running about 7 minutes and it used a solid 27 seconds of CPU time which is overall ~6% of the CPU.

an equivalent py3status configuration uses about 1% of the CPU. i just restarted with it, let it ran for 90 seconds, and it used about one second of CPU, which is actually less than a percent of CPU.

update: after over an hour (62m07s), 11 seconds of CPU times were used, thatโ€™s 0.2% usage. hereโ€™s a screenshot of that:

snap-20220621T190112

hereโ€™s the py3status configuration file: config.txt

i havenโ€™t made a wattage analysis, but i suspect this would have an equally negative impact on the battery life of my laptop. i certainly felt something was tugging at my battery when i spent a whole afternoon working without AC on sundayโ€ฆ but thatโ€™s of course more subjective, since the workload there varies quite a bit. i can provide powertop comparisons if thatโ€™s useful.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tobi-wan-kenobicommented, Jun 22, 2022

Glad to hear I was able to spark some ideas ๐Ÿ˜ƒ

Thanks a lot for the help you provided to this project!

1reaction
anarcatcommented, Jun 22, 2022

On 2022-06-21 23:18:18, tobi-wan-kenobi wrote:

wow, thanks for the detailed analysis!

youโ€™re welcome! i figured you desserved it ๐Ÿ˜ƒ

I suspect this is to a large part due to the fact that the updates happen once a second. Does the picture change if you set a longer update interval?

i have not tried tweaking the update intervals other than what you see in the config files. in py3status, in have a global, default 1 second interval. in bumblebee, i tried to tweak a bunch of intervals (battery 1m, CPU 5s, load 1m, time 30s, traffic 5s) to try to resolve the problem, but it mostly didnโ€™t have any effect.

I have considered switching to something completely event-based, but that would be a pretty big change for all the modules.

yeah, iโ€™m not sure itโ€™s worth it. FWIW, py3status looked at switching to asyncio as well in an eventual v4, but that never really materialized (thereโ€™s a v4 somewhere, but itโ€™s been idle for two years).

I will try to do some profiling as well (no clue yet how to do that in python)

thereโ€™s a bunch of tools, actually.

this is the builtin one:

https://docs.python.org/3/library/profile.html#module-cProfile

itโ€™s generally where I start, and never really looked any further. but if you do, you might want to skip the โ€œiโ€™m going to search on the webโ€ queue and look at thoseโ€ฆ

this one is a sampling profiler thatโ€™s pretty popular:

https://github.com/P403n1x87/austin

another similar one:

https://github.com/benfred/py-spy

this one does GPU profiling as well which might be relevant here:

https://github.com/emeryberger/scalene

this one is designed for scientific applications, not sure itโ€™s a good match:

https://github.com/pythonspeed/filprofiler

i also stumbled upon this which is a visual profiler:

https://github.com/nvdv/vprof

this is all i got, good luck!

โ€“ Si les triangles avaient un Dieu, ils lui donneraient trois cรดtรฉs. - Montesquieu, Lettres persanes

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Lower CPU Usage - NinjaOne
Learn why, and how to fix high CPU loads on your computer. ... In this article, we'll look at how to remedy high...
Read more >
High CPU usage: What are the potential causes? - IONOS
CPU usage indicates the degree of processing power that a PC's running processes require at any given moment. If it is too high,...
Read more >
Top 10 Ways to Fix OBS High CPU Usage in 2021
This article talks about the 10 solution to OBS high CPU usage fix, which you can opt for and get your problem sorted...
Read more >
Troubleshoot High CPU usage by the "System" process
Introduction. High CPU usage by the "System" process can often be caused by a hardware driver issue (bug, old version, incompatility etc).
Read more >
12 Ways to Fix OBS High CPU Usage [2022] - Movavi
Is OBS using too much CPU? In this guide, we cover twelve ways on how to reduce OBS CPU usage on your Windows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found