← Back to team overview

mythbuntu-bugs team mailing list archive

[Bug 589780] Re: mythfrontend wastes cpu cyles trying to access /etc/localtime

 

Same problem on my machine with mythfrontend running. A quick online
search says others have the same problem. Really, this probably needs to
be upstreamed to mythtv so they can fix this. My analysis is below:

One possible "workaround" is to set $TZ, because mythfrontend will try
to read that first and reading an environment variable is faster than
reading a file. However, this doesn't solve the problem. After setting
TZ, mythfrontend still continues to do some kind of polling and chew
cpu:

read(3, "A", 1)                         = 1
read(7, 0x9e5c258, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
gettimeofday({1282383613, 320879}, NULL) = 0
read(7, 0x9e5c258, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
clock_gettime(CLOCK_MONOTONIC, {362, 126183170}) = 0
poll([{fd=3, events=POLLIN}, {fd=8, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, -1) = 1 ([{fd=3, revents=POLLIN}])

read(3, "A", 1)                         = 1
read(7, 0x9e5c258, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
...

If you run strace -p [mythfrontend_pid] -e trace=gettimeofday -t, you
will see gettimeofday() getting called ~70 time a second. In gdb, you
can see this backtrace, and if you peek in the source code, you'll see
MythSignalingTimer::start(int msec) called with msec = 1000/70 in
libs/libmythui/mythmainwindow.cpp.

#0  gettimeofday () at ../sysdeps/unix/syscall-template.S:82
#1  0x4c4a7fb0 in QThread::usleep(unsigned long) () from /usr/lib/libQtCore.so.4
#2  0x434cb055 in MythSignalingTimer::run (this=Could not find the frame base for "MythSignalingTimer::run()".
) at mythsignalingtimer.cpp:73
#3  0x4c4a864e in ?? () from /usr/lib/libQtCore.so.4
#4  0x4cf6f96e in start_thread (arg=<value optimized out>) at pthread_create.c:300
#5  0x4ced5a4e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

This seems to be there to support animation. Are there animated mythtv
themes out there? I have no idea. My theme is static and doesn't require
any animating. Perhaps mythtv need to recognize this and only redraw the
screen on user action instead of 70 times a second.

-- 
mythfrontend wastes cpu cyles trying to access /etc/localtime
https://bugs.launchpad.net/bugs/589780
You received this bug notification because you are a member of Mythbuntu
Bug Team, which is subscribed to Mythbuntu.

Status in Mythbuntu, Ubuntu derivative focused upon MythTV: New

Bug description:
Mythfrontend constantly uses about 15% CPU which is enough to cause heat problems in my quiet frontend box.  And it wastes power too of course.

When connecting to the process with strace to see what's going on, here's what we get repeating as fast as the terminal can print it:

stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=3543, ...}) = 0
read(7, 0x13a9eb4, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=8, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 13) = 0 (Timeout)
read(7, 0x13a9eb4, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
read(7, 0x13a9eb4, 4096)                = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=8, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
read(7, 0x13a9eb4, 4096)                = -1 EAGAIN (Resource temporarily unavailable)

And /etc/localtime on my system is this:

root@ubuntu:~# ls -l /etc/localtime
lrwxrwxrwx 1 root root 30 2010-06-04 09:37 /etc/localtime -> /usr/share/zoneinfo/US/Central

So it should be valid.

Using lsof indicates nobody is using the file.





References