| Summary: | tdepowersave consuming almost 100% of CPU | ||
|---|---|---|---|
| Product: | TDE | Reporter: | David C. Rankin <trin> |
| Component: | non-core programs | Assignee: | Francois Andriot <albator78> |
| Status: | RESOLVED FIXED | ||
| Severity: | blocker | CC: | ac586133, albator78, bugwatch, kb9vqf, slavek.banko, trin |
| Priority: | P5 | ||
| Version: | R14.0.0 [Trinity] | ||
| Hardware: | Other | ||
| OS: | Linux | ||
| Compiler Version: | TDE Version String: | ||
| Application Version: | Application Name: | ||
| Attachments: |
tdelibs : reduce CPU eagerness when using tdepowersave
tdepowersave : use the "battery only" loop of tdehwlib, instead of "all stateless devices" loop tdelibs : reduce CPU eagerness when using tdepowersave (2) |
||
|
Description
David C. Rankin
2014-03-06 15:36:40 CST
Here is where the tdepowersave generates all the error (TQEventLoop::activateTimers) : TQTimerEvent (timerId=122, this=0xbf894650) at kernel/ntqevent.h:169 169 kernel/ntqevent.h: No such file or directory. TQEventLoop::activateTimers (this=this@entry=0x98a9d38) at kernel/qeventloop_unix.cpp:564 564 kernel/qeventloop_unix.cpp: No such file or directory. TQApplication::sendEvent (receiver=0x9977db0, event=event@entry=0xbf894650) at kernel/qapplication.cpp:2456 2456 kernel/qapplication.cpp: No such file or directory. 2457 in kernel/qapplication.cpp TQEventLoop::activateTimers (this=this@entry=0x98a9d38) at kernel/qeventloop_unix.cpp:565 565 kernel/qeventloop_unix.cpp: No such file or directory. Hi, On my PCLinuxOS non-official TDE remaster, I used to set TDE Powersave to maximum CPU performance to avoid this problem, so I can confirm that the problem was present in 3.5.13.1 and in 3.5.13.2 too. On an underpowered lappy such as my first-gen Asus EEE, the computer was almost unusable with the default setting. -Alexandre Created attachment 1999 [details]
tdelibs : reduce CPU eagerness when using tdepowersave
Hello, I've investigated the "tdepowersave constantly uses 5% CPU" issue.
I've found out that it is due to having 2 hardware polling loops running inside the TDE HW library:
- A loop running every 500ms for polling CPU informations
- A loop running every 1000ms for polling other "stateless" devices information
I've found out that, by default, each loops are equally wasting ressources (e.g. each loops causes ~2.5% constant cpu usage). So, both of them have to be fixed.
The general problem is that the code contains several loops (e.g. loop through each CPU core) which in turn contain several CPU or I/O consuming functions.
Example: I have 6 core hyperthread CPU (so 12 logical cores). For each core, we need to read about 10 files in SYSFS. As a result, the CPU polling loop opens, reads, and closes 12*10 = 120 files on my computer every 500ms !!!
The attached patches changes the following:
About CPU polling loop:
- Replaces the "readLine()" methods with "read()" methods, which are much faster (especially for parsing /proc/cpuinfo which was really slow).
- Add missing "else" statements, to avoid having useless string comparison in loops.
- Add a "cpu device cache" dictionnary, which avoids the slow parsing of all devices at every loop iteration (avoid calling "findBySystemPath()" which is slow)
- Consider that most power related features (cpu available governors, min/max frequency ...) are the same on all CPUs, to avoid scanning these values on each CPU; now we only scan the first CPU and apply the features to all others.
Now the CPU loop is about 10 (ten !) times faster than it originally was !
About the StateLess device loop:
The problem is that it causes rescan of almost ALL devices in the computer; we are only interested in batteries here, so this is a lot of useless stuff ...
I've implemented a 3rd loop, which is dedicated to polling batteries only, every 5 seconds.
In order to use this, we need to patch tdepowersave as well.
I've also left (but disabled) the small profiling code I've used to find where the CPU time was wasted.
Created attachment 2000 [details]
tdepowersave : use the "battery only" loop of tdehwlib, instead of "all stateless devices" loop
Created attachment 2003 [details]
tdelibs : reduce CPU eagerness when using tdepowersave (2)
Small bugfix on tdelibs patch.
Comment on attachment 1999 [details] tdelibs : reduce CPU eagerness when using tdepowersave Attachment 1999 [details] pushed to GIT in hash 3c9d481. Comment on attachment 2003 [details] tdelibs : reduce CPU eagerness when using tdepowersave (2) Sorry, I didn't realize that Attachment 2003 [details] superseded Attachment 1999 [details]. Fixed in GIT hash 1afbea2. Comment on attachment 2000 [details] tdepowersave : use the "battery only" loop of tdehwlib, instead of "all stateless devices" loop Attachment 2000 [details] Pushed to GIT in hash f43aac0. All patches have been pushed to GIT. Please test and mark RESOLVED FIXED if the problem has been fixed. Thanks for reporting, and thanks to Francois for the patches and the tdehwlib performance improvements! I'm still seeing tdepowersave eating 100% CPU after many hours of running on Ubuntu Maverick; changing status back to NEW. (In reply to Timothy Pearson from comment #10) > I'm still seeing tdepowersave eating 100% CPU after many hours of running on > Ubuntu Maverick; changing status back to NEW. This test was carried out with or without a commit f43aac0e? Patches from bug 2052 in any case reduce the number and frequency of dbus calls. I'm waiting for comments and testing :) It looks like the fix for Bug 2052 also fixed the high CPU usage on my laptop. Marking as RESOLVED FIXED since I seem to have been the only one with a residual problem. Thanks all for the patches! |