[mythtv-users] Optimizing MythTV for AMD64

Robert Tsai rtsai1111 at comcast.net
Sun Apr 3 21:12:03 UTC 2005


On Sun, Apr 03, 2005 at 11:21:40AM -0400, Kyle Rose wrote:
> I posted the following on my homepage this morning:

Cool. I'm not cool enough to have my own domain (or even my own
website), so I'll just let this get buried in the e-mail archives.

I've gotten started with MythTV for about a few weeks and am almost
comfortable enough with it to cancel my cable subscription, get
another HD-3000 card, and give my TiVo to my younger brother. My
combined frontend-backend system:

	- AMD64 3500+ Winchester
	- single HD-3000
	- Pretty stock debian pure64 (gcc-3.3)
	- NVidia FX5200 AGP DVI output
	- linux kernel 2.6.9
	- stock PCHDTV 1.6 driver patches from pchdtv.com
	- nvidia drivers as described on debian amd64 alioth website.
	- MythTV CVS, updated every week or so, compiled with gcc-3.4.
	- XFree86 configured at 960x540
	- MythTV GUI configured at 856x480+56+32 and +2% vertical
	  overscan. The GUI geometry is to deal with TV overscan. I
	  tried an Audio Authority 9A60 adapter, but that only got me
	  up to 952x504, and it always messed up the convergence on my
	  RPTV. So I'm back to DVI. The vertical overscan adjustment
	  is for non-HD NBC (Conan O'Brien). There is always a white
	  bar of static at the top of the display that I think is
	  somehow part of the signal, so I use the overscan adjustment
	  to get rid of it.

Let's go through the list:

> It has taken quite some time for MythTV to get to the point where it
> can reasonably be used with this configuration. Recently, a version
> of ffmpeg that appears to be optimized for AMD64
> <http://www.x86-64.org/> has been imported into the Myth CVS
> repository: to get this, make sure to uncheck the "uselibmpeg"
> option in Setup/TV Settings/Playback. However, this alone isn't
> sufficient.

Thanks! This alone has actually been pretty good for me. I'm using NBC
"Law & Order" as a test clip. I think that is 1080i based on what I've
read about various networks, but I don't know how to just examine the
data file to extract this information. I think it would be kind of
cool for the Myth GUI (or MythWeb) to provide some interface for
looking at technical data for recorded programs (for me, "technical"
would be gratuitous geek information like 720p/1080i, SD broadcast
over HD, etc.). I don't have any FOX recordings handy, so I can't
provide any results for 720p (I tend to aggressively delete shows when
I'm done watching them, and haven't yet learned to keep them around
for debugging/tinkering).

Anyway, using libmpeg, I run at about 75-85% CPU. Turning off libmpeg,
I am now down to about 50% CPU. In both cases, this is about 12% for
XFree86. Perhaps by coincidence, this confirms your reported CPU
numbers below (although we have different CPUs).

What kind of deinterlace algorithm are you using? I'm using Bob.
(Would that even be relevant to this performance discussion?)

> While I can't pinpoint the exact problem, I changed two major things in 
> one day that resulted in much improved performance:
> 
>   1. /Cross/Downgraded from Debian <http://www.debian.org/> gcc-3.4 to
>      Ubuntu <http://www.ubuntulinux.org/> Hoary./ This is a non-trivial
>      operation if you are not used to screwing with Debian packages a
>      lot. I still find old pieces of gcc-3.4/4.0-based packages now and
>      then, and need to reinstall them from Ubuntu's archive when I find
>      them. I recommend reinstalling from scratch if you aren't
>      comfortable with recovering from broken libc packages by hand. :)

Just curious:

	- Have you been using amd64-gcc-3.4 from the start, or had you
	  tried pure64 (gcc-3.3) before? I'm still in my enamored
	  honeymoon phase with MythTV, so I haven't started really
	  poking at my setup yet.

	- What was the motivation for going to Ubuntu? I've been a
	  long-time debian user, so I initially just tried pure64, and
	  it didn't give me any problems. Some of the philosophy is
	  admittedly sometimes frustrating (slow releases, non-free
	  software), but the stability has proven itself to me a few
	  times as well (including the recently alleged qt-3.4 DST
	  shenanigans people have been reporting).

>   2. /Upgraded my kernel to 2.6.11.6./ I actually don't think this
>      was part of the performance improvement, but it was a variable,
>      so I didn't want to leave it out. If you have stability
>      problems with CONFIG_PREEMPT_BKL (preempting the big kernel
>      lock), turn it off; I did.

I've been wanting to upgrade, but pchdtv.com only has driver patches
to the 2.6.9 kernel. The reason I want to upgrade is because there is
a bug in the header files related to <linux/cdrom.h> that I have to
patch my way around (which I've told myself is easier than upgrading
the pchdtv patches to a more recent kernel).

> In sum, my configuration looks like the following:
> 
>    * Hardware: Dual Opteron 244; Tyan <http://www.tyan.com/> Thunder
>      K8W S2885 mobo w/AMD-81x1 I/O interfaces; NVidia
>      <http://www.nvidia.com/> FX5600 AGP; 4 GB PC2700 (333MHz) dual DDR
>      SDRAM; Creative <http://www.creative.com/> SB Live! 5.1 with coax
>      S/PDIF
>    * Distribution: Ubuntu Hoary
>    * Linux: 2.6.11.6 (See my kernel .config
>      <http://www.krose.org/%7Ekrose/projects/mythtv/tyan.config>)
>    * ALSA drivers: 1.0.8 (alsa-source 1.0.8-4ubuntu4)
>    * NVidia drivers: 7167 (nvidia-kernel-source 1.0.7167-0ubuntu25)
>    * MythTV configuration: CVS as of 2005-Apr-02. Configuration
>      options: --disable-audio-arts --disable-audio-jack --disable-lirc
>      --disable-joystick-menu --disable-firewire --disable-ivtv
>      --disable-xrandr --enable-opengl-vsync --enable-memalign-hack
>      --cpu=x86_64

So this is implicitly --disable-xvmc, right? I also can't use XvMC.
Myth can't start with some kind of xvmc "can't setup context" problem.

Which drivers are you using for your HD-2000/HD-3000 cards? If you are
on 2.6.11, I'm guessing that you've manually fixed up your patches, or
does Ubuntu provide this?

>    * MythTV patches: [broken pthread_rwlock_*
>    <http://www.krose.org/%7Ekrose/projects/mythtv/broken_pthread_rwlock.diff>]

This has been great. Thanks.

>    * MythTV compilation: gcc-3.3, because the required Ubuntu packages
>      (e.g., libGLU, libqt-mt) are compiled with gcc-3.3 and link with
>      libstdc++5. I use make CC="gcc-3.3" CXX="g++-3.3" LINK="g++-3.3"
>      to build.

As I mentioned above, I use gcc-3.4. The reason is because with
gcc-3.3 I get this problem:

	gcc-3.3 -c -pipe -march=k8 -w -O3 -Wall -Wno-switch
		-fomit-frame-pointer -fPIC -fno-common -D_REENTRANT
		-DMMX -DUSING_OPENGL_VSYNC -D_GNU_SOURCE
		-D_FILE_OFFSET_BITS=64 -DPREFIX=\"/usr/local\"
		-DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED
		-I/usr/share/qt3/mkspecs/default -I.
		-I/usr/local/include -I/usr/include/qt3 -o cpu_accel.o
		cpu_accel.c
	cc1: error: bad value (k8) for -march= switch
	cc1: error: bad value (k8) for -mcpu= switch

I'm just guessing that maybe this new-ish k8 architecture hasn't been
backported to gcc-3.3? And I guess Ubuntu has it?

>    * MythTV config: turn off libmpeg decoding; use "ALSA:iec958" for
>      the sound device; turn on AC3 passthrough; turn on extra audio
>      buffering

As mentioned above, turning off libmpeg decoding has helped my CPU.

This is completely irrelevant, but I have to use /dev/dsp for my audio
device, and have to turn off AC3 passthrough. I haven't been using
"extra audio buffering" because it was turned off by default. But I'm
not very familiar with audio configuration under Linux. I just know
that this works for me, and I have digital SPDIF optical output to my
receiver.

> Performance improved significantly under this configuration. The
> following tests were performed with a playback window size of
> 1066x600 (16:9).
> 
>    * Playback of a specific 1080i clip (CBS football) went from >99%
>      of one CPU (with dropped frames) under the old config to ~55%
>      of one CPU for mythfrontend and 15% for X.org with smooth
>      playback.
>    * Playback of a specific 720p clip (FOX "24") went from >99% of
>      one CPU (with dropped frames) under the old config to ~40% of
>      one CPU for mythfrontend and 15% for X.org with smooth
>      playback.
> 
> Furthermore, at full size (1280x1024 with the video letterboxed to
> 16:9), playback still runs smoothly, though 1080i playback consumes
> close to 100% of one CPU for mythfrontend. Not clear why the
> playback window size should matter with XVideo, but it does.
> 
> If you have success with this configuration, I'd love to hear about
> it. If you have problems and are able to determine what I've left
> out, let me know so I can add the appropriate config elements.

In summary, turning off libmpeg has been good so I can confirm your
results (although it sounds like I am more happy with that
configuration change than you are).

I don't really have any major problems with your config (minor
difference in audio configuration that I don't care about), but I do
have a few miscellaneous questions posed above.

Thanks,
--Rob


More information about the mythtv-users mailing list