High CPU load
Steps to reproduce
- Simply start Telegram
- Let it run for a while (could be hours or even days)
- At some point it will start consuming lots of CPU
Expected behaviour
It shouldn't spend all that CPU load
Actual behaviour
It just consumes CPU time till the program is restarted
Configuration
Operating system: Fedora Linux 25 on one i7 laptop and one i5 desktop. Same thing on an Ubuntu 16.04 laptop.
Version of Telegram Desktop: 1.1.11 (previous versions too. IIRC 1.0 was ok) Used theme: Any theme
Logs:
Insert logs here (if necessary)running: top -H -p
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5470 smee 20 0 2686276 653620 100172 S 10.3 4.0 8:19.68 QThread
13349 smee 20 0 2686276 653620 100172 S 9.0 4.0 7:38.81 QThread
13346 smee 20 0 2686276 653620 100172 S 7.7 4.0 6:25.81 QThread
5471 smee 20 0 2686276 653620 100172 S 6.7 4.0 5:41.01 QThread
5482 smee 20 0 2686276 653620 100172 S 6.0 4.0 5:39.49 QThread
13348 smee 20 0 2686276 653620 100172 S 4.7 4.0 3:56.05 QThread
4829 smee 20 0 2686276 653620 100172 R 4.0 4.0 4:22.86 QThread
13347 smee 20 0 2686276 653620 100172 S 3.7 4.0 3:12.62 QThread
27411 smee 20 0 2686276 653620 100172 S 1.7 4.0 22:55.85 Telegram
27412 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:33.49 QXcbEventReader
27413 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:06.78 QDBusConnection
27415 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:13.68 Qt bearer threa
27416 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:00.00 gmain
27417 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:00.08 gdbus
27432 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:00.20 QThread
27433 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:01.95 QThread
27434 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:00.00 QThread
27436 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:06.02 MTP::internal::
4205 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:00.00 Qt HTTP thread
27321 smee 20 0 2686276 653620 100172 S 0.0 4.0 0:00.00 Qt HTTP thread
Same problem on i7/macOS Sierra/tdesktop 1.1.10
I can reproduce this problem too on Ubuntu 16.04 (laptop)
I had the same problem here, i7 desktop, and a laptop, both with Fedora 25.
I've noticed this too on Ubuntu, even more so when someone is typing a message/just posted it seems to spike up. Which is especially problematic when gaming.
Same here. also lots of disk usage ... i7/laptop/Win10
Is there a way we could help the developers debug the issue? It seems like it's not OS or build specific..
@kmare Is Sticker/GIF panel enabled? Is something playing? Are there any GIFs on screen? What if you defocus the app?
@stek29 No, the sticker/gif panel is hidden, nothing is playing, no gifs on scree. Moving the focus off the app won't help either. The only way to kill all these QThreads is to quit the app and restart it. So yeah, unfortunately I still haven't figured out what's causing the spawning of all these QThreads causing the high cpu load. At this moment, it looks so random as it could happen after a few minutes or a day.
I was basically facing the same issue of high cpu load, as high as 140% on mac osx sierra with latest telegram desktop update (1.1.10 as of now) but I've had this issue on previous versions too, after digging for a little bit I found out that my local storage has caused an integer overflow (2244).
And this is the local storage:
After clearing the local storage now the issue seems to be fixed for me:

@silverfoxy that's actually interesting. I checked my local storage and it seems fine though. So I guess, at least in my case, it has to be something else. Thank you for reporting that though!
same problem in ubuntu 14.04 and 16.04. It starts to use a lot of cpu for no reason.
Same here on Debian (Sid) 32bit on a Thinkpad T42p, Telegram takes more and more and more CPU after a (short) while. Tracing the process does not show much more than endless calls to clock_gettime, poll, recvmsg and futex:
[pid 32000] poll([{fd=6, events=POLLIN}, {fd=10, events=POLLIN}, {fd=12, events=POLLIN}, {fd=13, events=POLLIN}], 4, 399 <unfinished ...>
[pid 32031] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=102094921}) = 0
[pid 32031] poll([{fd=30, events=POLLIN}], 1, 0) = 0 (Timeout)
[pid 32031] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=112063820}) = 0
[pid 32031] poll([{fd=30, events=POLLIN}], 1, 0) = 0 (Timeout)
[pid 32031] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=112284246}) = 0
[pid 32031] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=112347384}) = 0
[pid 32031] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=112414434}) = 0
[pid 32031] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=112492100}) = 0
[pid 32031] poll([{fd=30, events=POLLIN}], 1, 30 <unfinished ...>
[pid 32030] <... poll resumed> ) = 0 (Timeout)
[pid 32030] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=115244212}) = 0
[pid 32030] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=115316570}) = 0
[pid 32030] clock_gettime(CLOCK_MONOTONIC, {tv_sec=451257, tv_nsec=115402338}) = 0
[pid 32030] write(6, "\1\0\0\0\0\0\0\0", 8) = 8
[pid 32000] <... poll resumed> ) = 1 ([{fd=6, revents=POLLIN}])
[pid 32030] clock_gettime(CLOCK_MONOTONIC, <unfinished ...>
[pid 32000] read(6, <unfinished ...>
[pid 32030] <... clock_gettime resumed> {tv_sec=451257, tv_nsec=115622205}) = 0
[pid 32000] <... read resumed> "\1\0\0\0\0\0\0\0", 16) = 8
[pid 32030] poll([{fd=31, events=POLLIN}], 1, 0 <unfinished ...>
[pid 32000] clock_gettime(CLOCK_MONOTONIC, <unfinished ...>
[pid 32030] <... poll resumed> ) = 0 (Timeout)
This is a relatively recent problem, it started about a month ago. Earlier versions did not show this behaviour.
I attached a running Telegram process to strace to see where things went berzerk. Telegram behaved nicely, 0.1% CPU, nothing special. Messed around a bit, nothing special.
Then I happened to move the pointer over that #%#¤&/%/%/ smiley button which I'd rather ditch yesterday than today. The blasted popup appeared again with a hoard of moving GIF images. I clicked outside of it to get rid of the dreaded things and had a look at the trace. 5 new threads had been launched and the trace was going wild, suddenly Telegram was hogging 25% CPU. Mind, the popup was gone, no moving images in sight, all peace and quiet on the surface. Below the surface it seems some QThreads were busy doing something anyway, something which took a lot of CPU.
Then I switched the horrible emjoistickergif popup to the 'emoji' tab and closed it. The CPU hoarding stopped. Switched back to the moving misery, closed popup, NO CPU HOARDING. Switched back and forth a few times, sometimes it started hoarding CPU, other times it didn't. The interesting observation is that I never got any hoarding problems when the popup was set to 'emoji' or 'stickers' but did get it when the thing was set to 'gifs'.
@Yetangitu thank you for "discovering" that! I'll take a look at that too and see if this is what is causing the 100% CPU load with telegram spawning all these QThreads.
I can confirm what @Yetangitu said! It really works! So basically, as soon as you see the CPU load going up cause of telegram, just click on the emoji/stickers/gifs icon once, click on it again and the telegram CPU load will go back to where it should be idling! If anyone else could confirm, please do so. Hopefully the developers will find a solution.
From my observations it is enough to make sure that the popup is not set to 'gifs' before it is closed to avoid Telegram hogging the CPU. I have not seen any hogging since doing this.
#4238
Same on High Sierra Mac OS, but 1.1.13alpha takes much less resources.
@sstyle Please try the current version, v1.2.6.
@auchri I tried (you can see it here #4238) and found that 1.1.13 much better, but still has this issue.