Bug 128042 - [PATCH] multimedia/xvid: use assembly for better performance
Summary: [PATCH] multimedia/xvid: use assembly for better performance
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dmitry Marakasov
Depends on:
Reported: 2008-10-13 05:30 UTC by Carlos Santos
Modified: 2008-10-13 14:00 UTC (History)
0 users

See Also:

file.diff (1.37 KB, patch)
2008-10-13 05:30 UTC, Carlos Santos
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Santos 2008-10-13 05:30:01 UTC
From a message set by Michel Talon to freebsd-ports on Oct 9 2008:

"Trying to encode with mencoder and the xvid codec, I discovered that it is awfully slow (around 3 frames/s on my P4 machine). So I played a little bit with the options in the Makefile without any success. Finally I understood that the cause was that the build system requires nasm, but doesn't use it! There are several assembly files in the xvid codec which are not used due to that. The solution i have found by looking at the configure script is to install the yasm port. Then the build system picks the yasm dependency and compiles the assembly files, which enables SSE instructions. The net result is that, without any other tweak, i now encode the same stuff at 11 frames/s.

So to be short, multimedia/xvid should require a dependency on yasm."

Sean Winn noted that the problem comes because the configure script tries to use the -r option which yasm has but not nasm. So the xvid people had really yasm in view when doing their work. Fixing the configure script should be done upstream, but it seems that the xvid project is somewhat asleep, so better use yasm in the Makefile on which there is control.

I (Casantos) gave it a try and found that configure needs some help on AMD64 because it expects the architecture name to be "x86_64", not "amd64".

Fix: The attached patch fixes the build in order to use yasm. According to Michel Talon, "the performance improvement obtained by using SSE instructions in the assembly files is astounding. I could not beleive what i was seeing, basically an x 4 improvement, that is the code perfectly parallelizes the computations on the 128 bits registers."

The patch also eliminates the pkg-plist file, using PLIST_FILES instead, since the port installs only three files and one symbolic link.

Patch attached with submission follows:
How-To-Repeat: Build multimedia/xvid version 1.1.3_1.
Comment 1 Stefan Walter freebsd_committer 2008-10-13 08:07:15 UTC
Hi Carlos,

just a quick note: you probably meant to increment PORTREVISION in the
Makefile, not PORTEPOCH.

Comment 2 Carlos Santos 2008-10-13 13:33:18 UTC
On Mon, Oct 13, 2008 at 4:07 AM, Stefan Walter <stefan@freebsd.org> wrote:
> Hi Carlos,
> just a quick note: you probably meant to increment PORTREVISION in the
> Makefile, not PORTEPOCH.
> Regards,
> Stefan

Yes, that was the intention. Thanks for spotting it.

cd /usr/ports/sysutils/life
make clean
Comment 3 Dmitry Marakasov freebsd_committer 2008-10-13 13:38:13 UTC
Responsible Changed
From-To: freebsd-ports-bugs->amdmi3

I'll take it.
Comment 4 Dmitry Marakasov freebsd_committer 2008-10-13 13:49:47 UTC
State Changed
From-To: open->closed

Committed. Thanks!
Comment 5 dfilter service freebsd_committer 2008-10-13 13:49:52 UTC
amdmi3      2008-10-13 12:49:38 UTC

  FreeBSD ports repository

  Modified files:
    multimedia/xvid      Makefile 
  Removed files:
    multimedia/xvid      pkg-plist 
  - Fix port to actually use assembly on i386 and amd64, providing up to 4x coding speedup
  - Change pkg-plist to PLIST_FILES as there are only 4 files in there
  PR:             128042
  Submitted by:   Carlos Santos <unixmania at gmail dot com>
  Revision  Changes    Path
  1.30      +14 -3     ports/multimedia/xvid/Makefile
  1.7       +0 -4      ports/multimedia/xvid/pkg-plist (dead)
cvs-all@freebsd.org mailing list
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"