[MPlayer-dev-eng] Really nasty quick hack for making mp3lib faster...

Thomas Orgis thomas-forum at orgis.org
Sun May 30 23:24:40 CEST 2010


Hi,

the discussion about the upcoming mpg123 patch brought some funky
performance issues to the light, namely the mp3lib internal code
changing performance when changing the ad_mpg123.c code.
We've seen something like that before in mpg123 ... this is an
accidental alignment issue.

Recap of the issue: One version of libmpcodecs/ad_mpg123.c caused that
measurement (Linux/x86-64, Core2Duo P8600):

mplayer-svn$ for i in mpg123 mp3; do echo $i;  time ./mplayer -ao pcm:file=/dev/null  -quiet -ac $i ../../convergence_-_points_of_view/*.mp3 > /dev/null ; done
mpg123

real	0m6.173s
user	0m6.107s
sys	0m0.051s
mp3

real	0m5.823s
user	0m5.769s
sys	0m0.042s

Another version triggered that:

mplayer-svn$ for i in mpg123 mp3; do echo $i;  time ./mplayer -ao pcm:file=/dev/null  -quiet -ac $i ../../convergence_-_points_of_view/*.mp3 > /dev/null ; done
mpg123

real	0m6.195s
user	0m6.127s
sys	0m0.048s
mp3

real	0m6.372s
user	0m6.306s
sys	0m0.050

Now... there is an easy hack to keep mp3lib's performance high: Make
 the static memory in there aligned to 64 bytes.

mplayer-svn$ perl -pi -e 's:aligned\(\d+\):aligned(64):g' mp3lib/*.c

And observe:

mplayer-svn$ for i in mpg123 mp3; do echo $i;  time ./mplayer -ao pcm:file=/dev/null  -quiet -ac $i ../../convergence_-_points_of_view/*.mp3 > /dev/null ; done
mpg123

real	0m6.200s
user	0m6.146s
sys	0m0.040s
mp3

real	0m5.818s
user	0m5.770s
sys	0m0.039s

Nifty, eh? My changes in other parts of the mplayer binary apparently
caused accidental increase in alignment of some data structures.

Now I only need to revisit mpg123 again to see if we still
have something left to do in that direction. We already align dynamic
memory at 64 bytes, but there may still be some optimization left to
do. Especially since we really got some improved SSE2 code going on
there that should show some benefit from mp3lib.

And now ... I'll leave you to wonder about what other codecs might be
affected by that;-)


Alrighty then,

Thomas.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100530/1659672b/attachment.pgp>


More information about the MPlayer-dev-eng mailing list