View previous topic :: View next topic |
Author |
Message |
tactless l33t
Joined: 14 Jul 2002 Posts: 642 Location: Mitzpe Adi, Israel
|
Posted: Thu Oct 07, 2004 10:41 am Post subject: Symlinking libraries for better performance [Sticky request] |
|
|
We like Gentoo because we compile things with optimizations for our processors. However, many games come with unoptimized, often older versions of libraries. In 9 cases out of 10, replacing the game's supplied library with our own version - or better yet, a symbolic link (symlink) to it, gives a nice performance boost.
Here's the general method:
Code: | # cd /usr/local/games/doom3-demo
# ls
bla bla bla bla
libgcc_s.so.1 <-- these two look familiar!
libstdc++.so.5
bla bla bla bla
# locate libgcc_s.so.1
/usr/local/games/doom3-demo/libgcc_s.so.1
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1 <-- If it's in /usr/lib, it's the system-wide version that we've compiled
# mv libgcc_s.so.1 libgcc_s.so.1.old <-- always back up
# ln -s /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1
# ls -l libgcc_s.so.1
lrwxr-xr-x 1 root root 54 Oct 5 21:25 libgcc_s.so.1 -> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1
|
Repeat for *.so and *.so.* in any game directories. These two file I've mentioned are good examples from Doom 3.
For UT2004, the System directory contains libSDL-1.2.so.0 and openal.so - symlinks are done just like for Doom 3.
I'm sure that many other binary-only games can get a performance boost this way. _________________ Tactless
"If it wasn't for fog, the world would run at a really crappy framerate."
Jabber: tactless@amessage.info |
|
Back to top |
|
|
GrayFox Apprentice
Joined: 24 Jan 2004 Posts: 183 Location: Germany
|
Posted: Thu Oct 07, 2004 11:48 am Post subject: |
|
|
This does not work with gcc3.4 here. _________________ Random Stuff |
|
Back to top |
|
|
grover Tux's lil' helper
Joined: 27 Sep 2002 Posts: 77 Location: Melbourne, Australia
|
Posted: Thu Oct 07, 2004 11:58 am Post subject: |
|
|
GrayFox wrote: | This does not work with gcc3.4 here. |
Link against /usr/lib/libstdc++.so.5 instead and it should work fine. |
|
Back to top |
|
|
tactless l33t
Joined: 14 Jul 2002 Posts: 642 Location: Mitzpe Adi, Israel
|
Posted: Thu Oct 07, 2004 1:56 pm Post subject: |
|
|
You shouldn't take it from my paths - use the locate (or find) command to figure out where the libraries are on your system. _________________ Tactless
"If it wasn't for fog, the world would run at a really crappy framerate."
Jabber: tactless@amessage.info |
|
Back to top |
|
|
ConVicTioN Tux's lil' helper
Joined: 24 Sep 2004 Posts: 80 Location: Orlando
|
Posted: Thu Oct 07, 2004 6:12 pm Post subject: |
|
|
Nice tweak works for most games! _________________ I think there for I am? |
|
Back to top |
|
|
ashtophet Guru
Joined: 08 Aug 2004 Posts: 397
|
Posted: Thu Oct 07, 2004 6:26 pm Post subject: |
|
|
really good tip...
|
|
Back to top |
|
|
COiN3D Guru
Joined: 02 Aug 2004 Posts: 543 Location: Munich, Germany
|
|
Back to top |
|
|
antonlacon Apprentice
Joined: 27 Jun 2004 Posts: 257
|
Posted: Thu Oct 07, 2004 9:12 pm Post subject: |
|
|
america's army & nwn benefit from this as well. |
|
Back to top |
|
|
Konsti l33t
Joined: 10 Dec 2002 Posts: 691
|
Posted: Thu Oct 07, 2004 10:35 pm Post subject: |
|
|
Are there any benchmarks which evidence the increase of performance?
I have a doom3 demo installation here on an amd64 system and renamed the *.so to *.so.OLD in the game directory, expecting links from system libs to be required.
To check that I fired up doom3 before creating the links. It run absolutely normal then. So I suspect that doom3 prefers system libs anyway. But may be, that is an amd64+emul32 lib behaviour. I must suspect that, because:
1.) no "timedemo demo1" in demo version
2.) ldd does not work on 32Bit binaries (btw., is there a emul32 ldd somewhere, and why are the 32Bit compatibility libs not compiled with an crosscompiler in system like the other stuff, has there be to implement one? could and would do that...).
How dos an ldd on the doom3 binaries and libs look like on a pure 32Bit system? |
|
Back to top |
|
|
sgaap l33t
Joined: 16 Aug 2002 Posts: 754 Location: Enschede, The Netherlands
|
Posted: Fri Oct 08, 2004 1:29 am Post subject: |
|
|
Hmm, I can play doom3 at 1024/high fine on windows, but it ran somewhat slower on linux (just a feeling, havent tested the differences yet), but after symlinking those libs to my own build version the game runs smooth on 1024/high (still a bit unstable though, giving me some segfaults sometimes, something that also happened with the original libs) _________________ In "old" Europe we already have a word for "pre-emptive strikes" mr Bush: its called "war" |
|
Back to top |
|
|
GrayFox Apprentice
Joined: 24 Jan 2004 Posts: 183 Location: Germany
|
Posted: Fri Oct 08, 2004 11:43 am Post subject: |
|
|
tactless wrote: | You shouldn't take it from my paths - use the locate (or find) command to figure out where the libraries are on your system. |
Of course it simply doesn't work with gcc 3.4. (I only tried replacing both libgcc and libstd++) _________________ Random Stuff |
|
Back to top |
|
|
grover Tux's lil' helper
Joined: 27 Sep 2002 Posts: 77 Location: Melbourne, Australia
|
Posted: Fri Oct 08, 2004 11:58 am Post subject: |
|
|
GrayFox wrote: | tactless wrote: | You shouldn't take it from my paths - use the locate (or find) command to figure out where the libraries are on your system. |
Of course it simply doesn't work with gcc 3.4. (I only tried replacing both libgcc and libstd++) |
emerge libstdc++-v3
That provides a library that is compatible with older versions of gcc and works with doom3. Doesn't make a difference to performance on my machine though. |
|
Back to top |
|
|
Rainmaker Veteran
Joined: 12 Feb 2004 Posts: 1650 Location: /home/NL/ehv/
|
Posted: Fri Oct 08, 2004 12:05 pm Post subject: |
|
|
my framerate in doom3 dropped from 25 to 20 fps.
Still, I think this has something to do with my system setup... _________________ If you can't dazzle them with brilliance, baffle them with bullshit. |
|
Back to top |
|
|
Gentii Guru
Joined: 01 Feb 2004 Posts: 306
|
Posted: Fri Oct 08, 2004 2:22 pm Post subject: |
|
|
I have gcc 3.4 . The symlinks worked, I can still launch the game after that, but not gain at all, it runs exactly the same as before. Same for ut2004. |
|
Back to top |
|
|
KozmoNaut Apprentice
Joined: 09 Dec 2002 Posts: 168 Location: Denmark
|
Posted: Fri Oct 08, 2004 5:49 pm Post subject: |
|
|
I went from 28.6 to 33.5 fps in Doom3 at 640x480 Medium detail, with muzzleflash, projectilelights and playershadow on.
Very acceptable. _________________ War. War never changes. |
|
Back to top |
|
|
Gentii Guru
Joined: 01 Feb 2004 Posts: 306
|
Posted: Fri Oct 08, 2004 9:12 pm Post subject: |
|
|
Maybe someone could explain why it does work for some people, and doesn't for others ? |
|
Back to top |
|
|
PrakashP Veteran
Joined: 27 Oct 2003 Posts: 1249 Location: C.C.A.A., Germania
|
Posted: Fri Oct 08, 2004 10:26 pm Post subject: |
|
|
Some use wiser and some use not so wise CFLAGS I would guess. |
|
Back to top |
|
|
zeek Guru
Joined: 16 Nov 2002 Posts: 480 Location: Bantayan Island
|
Posted: Sat Oct 09, 2004 3:26 am Post subject: Re: Symlinking libraries for better performance [Sticky requ |
|
|
tactless wrote: |
Code: | libgcc_s.so.1
libstdc++.so.5
|
|
Are you saying that these files came in the doom3 tarball? Very interesting, I didn't think redistribution of LGPL'd libraries was allowed in closed source applications. |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Sat Oct 09, 2004 10:35 am Post subject: |
|
|
they can re-distrobute them as long as any modifications they make are fed back the the project. As you can see they are on their own. If they merged the code into the Doom3 exe they would have had to give the entire doom code to us *muhahahah). Bu they did it correctly
What I dont understand is y ship them? pretty much all linux distro's will have these libaries. All they would have to do is hava a script that when it installs chaecks the version of libgcc and libstdc that is installed
It is a bit like at the back of the game box - "requred DirectX 9.0c to run under windows" so there are windows dependacies. Game makers have to start (well makeing more games) but also checkin gthe installed system
you know all that data that firsts flys past in a compilation - that is just MAKE checking installed libary versions to make sure it can compile. If the doom3 instller does not find the relevant version of the libs then prompt user to upgrade - this is best suited to Gentoo since there can be dependancies within the ebuild that will automagically upgrade for you) |
|
Back to top |
|
|
PrakashP Veteran
Joined: 27 Oct 2003 Posts: 1249 Location: C.C.A.A., Germania
|
Posted: Sat Oct 09, 2004 10:38 am Post subject: |
|
|
BTW, no need to do symlinking in case of doom. Just delete (or rename) the .so files... |
|
Back to top |
|
|
Gentii Guru
Joined: 01 Feb 2004 Posts: 306
|
Posted: Sat Oct 09, 2004 12:47 pm Post subject: |
|
|
PrakashKC wrote: | Some use wiser and some use not so wise CFLAGS I would guess. |
And what are wiser CFLAGS ? |
|
Back to top |
|
|
PrakashP Veteran
Joined: 27 Oct 2003 Posts: 1249 Location: C.C.A.A., Germania
|
Posted: Sat Oct 09, 2004 1:22 pm Post subject: |
|
|
CFLAGS which cause gcc to create fast and stable binaries... There are plenty of threads about it... |
|
Back to top |
|
|
KozmoNaut Apprentice
Joined: 09 Dec 2002 Posts: 168 Location: Denmark
|
Posted: Sat Oct 09, 2004 1:50 pm Post subject: |
|
|
Gentii wrote: | PrakashKC wrote: | Some use wiser and some use not so wise CFLAGS I would guess. |
And what are wiser CFLAGS ? |
Code: | CFLAGS="-march=pentium3 -mcpu=pentium4 -Os -s -funroll-loops -pipe" |
That's what I use. _________________ War. War never changes. |
|
Back to top |
|
|
-=GGW=- $ol!d $n4>|e Veteran
Joined: 12 Apr 2004 Posts: 1616 Location: USA
|
Posted: Sun Oct 10, 2004 8:11 pm Post subject: |
|
|
hmm... If I wanted to prelink a program and use the symlink trick.. would I prelink and then symlink, or symlink and then prelink. And everytime I re-prelink would I have to re-symlink? |
|
Back to top |
|
|
hermes_jr l33t
Joined: 26 Feb 2004 Posts: 701 Location: Moscow, Russia
|
Posted: Sun Oct 10, 2004 8:42 pm Post subject: |
|
|
Actually symlink should kinda reroute any library call. So link will always point to lib, no matter is it prelinked or not. Just create a symlink, then you can prelink-unprelink a program many times and it should work (anyway, works for me) . |
|
Back to top |
|
|
|