excessive CPU usage compared to alternative
See original GitHub issueBug 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.
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.
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:
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:
- Created a year ago
- Comments:8 (8 by maintainers)
Glad to hear I was able to spark some ideas ๐
Thanks a lot for the help you provided to this project!
On 2022-06-21 23:18:18, tobi-wan-kenobi wrote:
youโre welcome! i figured you desserved it ๐
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.
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).
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