Tdesktop: High power consumption on linux

Created on 15 Jun 2018  路  17Comments  路  Source: telegramdesktop/tdesktop

Steps to reproduce

  1. Launch Telegram app and let it run in background for some time
  2. Run PowerTop (https://01.org/powertop)
  3. Disconnect AC power (to see power consumption reported by battery)

Expected behaviour

Telegram is somewhere is the middle or at the bottom of power consumers list

Actual behaviour

Telegram is highest background consuming process.

Here is part of PowerTop overview output

Summary: 1007.2 wakeups/second,  0.0 GPU ops/seconds, 0.0 VFS ops/sec and 20.2% CPU use

Power est.              Usage       Events/s    Category       Description
  2.06 W     61.1%                      Device         Display backlight
  1.40 W    100.0%                      Device         USB device: USB Receiver (Logitech)
  382 mW     19.6 ms/s     144.2        Process        [PID 13090] /home/dmig/Telegram/Telegra
  373 mW     23.7 ms/s     124.1        Process        [PID 3417] /usr/lib/chromium-browser/ch
  368 mW    100.0%                      Device         USB device: Touchscreen (ELAN)
  347 mW      2.4 ms/s     162.4        Timer          tick_sched_timer

Chromium is always moving up-down the list, but telegram position is constant: 360-380mW. I beleive that's too much for process sitting in the background.

Configuration

Operating system: Ubintu 18.04
Version of Telegram Desktop: 1.3.7
Used theme: default

bug

Most helpful comment

A workaround is to set the timer slack, either via prctl(PR_SET_TIMERSLACK), or perhaps more easily, using something like for id in $(pgrep -w Telegram); do echo 15000000 | sudo tee /proc/$id/timerslack_ns; done.

This forcefully degrades Telegram's timer resolution, reducing the amount of wakeups and power consumption, but also the smoothness of animation; in my example, I set it to 15 ms, which roughly corresponds to 60 fps, but you can set it even higher with correspondingly increased jank. (Note that 15 ms timer resolution doesn't quite let Telegram reliably perform smooth animations at 60 fps, it's just a number I picked that isn't totally random.)

All credit for this workaround goes to the person who suggested it.

All 17 comments

I have the same problem, Telegram permanently consumes 1.3%-2.0% CPU according to htop. It started from version 1.2.18 and is still present in 1.3.7. Before that, namely in version 1.2.17, CPU load was 0.0%.

My operating system is Arch Linux. I tried both the official Telegram binary and a version compiled by Arch.

I don't know if it is related, but also on Windows Telegram (version 1.3.9) consumes a bit more than it did before.
Indeed, in the energy report computed by "powercfg /energy", Telegram is reported to have increased the timer resolution from 15,6 ms to around 1 ms. As reported here and here, this can lead to a 25% reduction in battery life.

PS I opened issue #4914 for this problem.

Just checked with latest version 1.3.9: background consumption reduced, but it's still the most hungry process.

When Telegram is in the background for a long time, reported consumption varies between 70-100mW. When window has focus, reported consumption varies between 200-600mW. 3-5 minutes later after been sent to background it reduces consumption to 100-150mW, much later back to 70-100.
Doesn't matter if window is closed (if it uses tray icon), minimized or just hidden.

This is a good change, but result is still worse than than shown by Chromium browser with 5-7 active tabs.

I observe same issue with in Ubuntu 18.10 on Dell 5855 and Dell 7285, with Telegram 1.4.

I'm on Pop!_OS 18.10 (Ubuntu 18.10) with cinnamon and when starting Telegram I get about 24% CPU usage. Once the app loads usage goes down to 0%. Hopefully, there is a big win here to reduce CPU on load.

I recently upgraded to 1.5.2 and this seems to be resolved. I'm now seeing a max of 3% CPU consumption and then down to 0%. The App also starts WAY faster.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Pop!_OS 18.10
Release:    18.10
Codename:   cosmic
$ uname -a
Linux satori 4.18.0-12-generic #13-Ubuntu SMP Wed Nov 14 15:17:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

peek 2018-12-17 17-25

@BrookeDot please, verify power consumption in powertop, as original reported did.

On Windows issue is still present even on version 1.5.2. Power consumption real time data from APC UPS: IDLE Pc not running Telegram is at about 43watts. Running Telegram in background with the system IDLE runs to 53-55 watts on my system. Closing Telegram and waiting for the system going in IDLE mode takes the power consumption back to 43watts. Same behaviour with Telegram 1.5.2 under Ubuntu Linux 18.04. I've noticed that even third parties Telegram based apps like Unigram UWP app show the same behaviour (maybe due to the fact that it's based on tdLib API)

Telegram-desktop 1.5.11-1build1 on Ubuntu Disco Dingo still does that. It's the second top consumer (first is ticks themselves) on powertop.

1.7.3 same problem, arch linux

I'm also seeing 0,6-2% CPU usage constantly, around 120 events/s as per powertop

Still persists on Linux. Especially if no internet connection is available. Without Telegram running I have 8W (powertop) and with Telegram running I get 14W consumption on my machine. The displaymanager (kwin in my case) shows also a lot of wakeups if Telegram has no internet connection.

So I think the tuning circle in the bottom left corner of Telegram Desktop may cause problems!

stracing telegram process shows that it polls several file descriptors each 5-7 milliseconds

@john-preston Could you evaluate giving this issue more priority? Especially when there is no network connection, i.e. if telegram-desktop is not useful at all it is hogging the battery besides draining more battery in idle than all those bloated electron apps i have running together.

Hey there!

This issue will be automatically closed in 7 days if there would be no activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

This is still an issue.

A workaround is to set the timer slack, either via prctl(PR_SET_TIMERSLACK), or perhaps more easily, using something like for id in $(pgrep -w Telegram); do echo 15000000 | sudo tee /proc/$id/timerslack_ns; done.

This forcefully degrades Telegram's timer resolution, reducing the amount of wakeups and power consumption, but also the smoothness of animation; in my example, I set it to 15 ms, which roughly corresponds to 60 fps, but you can set it even higher with correspondingly increased jank. (Note that 15 ms timer resolution doesn't quite let Telegram reliably perform smooth animations at 60 fps, it's just a number I picked that isn't totally random.)

All credit for this workaround goes to the person who suggested it.

Was this page helpful?
0 / 5 - 0 ratings