Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Symlinking libraries for better performance [Sticky request]
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
tactless
l33t
l33t


Joined: 14 Jul 2002
Posts: 642
Location: Mitzpe Adi, Israel

PostPosted: Thu Oct 07, 2004 10:41 am    Post subject: Symlinking libraries for better performance [Sticky request] Reply with quote

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
View user's profile Send private message
GrayFox
Apprentice
Apprentice


Joined: 24 Jan 2004
Posts: 183
Location: Germany

PostPosted: Thu Oct 07, 2004 11:48 am    Post subject: Reply with quote

This does not work with gcc3.4 here. :?
_________________
Random Stuff
Back to top
View user's profile Send private message
grover
Tux's lil' helper
Tux's lil' helper


Joined: 27 Sep 2002
Posts: 77
Location: Melbourne, Australia

PostPosted: Thu Oct 07, 2004 11:58 am    Post subject: Reply with quote

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
View user's profile Send private message
tactless
l33t
l33t


Joined: 14 Jul 2002
Posts: 642
Location: Mitzpe Adi, Israel

PostPosted: Thu Oct 07, 2004 1:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
ConVicTioN
Tux's lil' helper
Tux's lil' helper


Joined: 24 Sep 2004
Posts: 80
Location: Orlando

PostPosted: Thu Oct 07, 2004 6:12 pm    Post subject: Reply with quote

Nice tweak works for most games!
_________________
I think there for I am?
Back to top
View user's profile Send private message
ashtophet
Guru
Guru


Joined: 08 Aug 2004
Posts: 396
Location: Galiza

PostPosted: Thu Oct 07, 2004 6:26 pm    Post subject: Reply with quote

really good tip...

:)
_________________
O coração, se pudesse pensar, pararia. Fernando Pessoa
If heart could think, it would stop
Back to top
View user's profile Send private message
COiN3D
Guru
Guru


Joined: 02 Aug 2004
Posts: 543
Location: Munich, Germany

PostPosted: Thu Oct 07, 2004 7:44 pm    Post subject: Reply with quote

Is there a way to tweak Cedega (Binaries) with this method,too?
_________________
e17 documentation | Be free and use Jabber as your IM! | Combine IRC and IM
Back to top
View user's profile Send private message
antonlacon
Apprentice
Apprentice


Joined: 27 Jun 2004
Posts: 255

PostPosted: Thu Oct 07, 2004 9:12 pm    Post subject: Reply with quote

america's army & nwn benefit from this as well.
Back to top
View user's profile Send private message
Konsti
l33t
l33t


Joined: 10 Dec 2002
Posts: 691

PostPosted: Thu Oct 07, 2004 10:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
sgaap
l33t
l33t


Joined: 16 Aug 2002
Posts: 754
Location: Enschede, The Netherlands

PostPosted: Fri Oct 08, 2004 1:29 am    Post subject: Reply with quote

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
View user's profile Send private message
GrayFox
Apprentice
Apprentice


Joined: 24 Jan 2004
Posts: 183
Location: Germany

PostPosted: Fri Oct 08, 2004 11:43 am    Post subject: Reply with quote

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
View user's profile Send private message
grover
Tux's lil' helper
Tux's lil' helper


Joined: 27 Sep 2002
Posts: 77
Location: Melbourne, Australia

PostPosted: Fri Oct 08, 2004 11:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Rainmaker
Veteran
Veteran


Joined: 12 Feb 2004
Posts: 1650
Location: /home/NL/ehv/

PostPosted: Fri Oct 08, 2004 12:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
Gentii
Guru
Guru


Joined: 01 Feb 2004
Posts: 306

PostPosted: Fri Oct 08, 2004 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
KozmoNaut
Apprentice
Apprentice


Joined: 09 Dec 2002
Posts: 168
Location: Denmark

PostPosted: Fri Oct 08, 2004 5:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
Gentii
Guru
Guru


Joined: 01 Feb 2004
Posts: 306

PostPosted: Fri Oct 08, 2004 9:12 pm    Post subject: Reply with quote

Maybe someone could explain why it does work for some people, and doesn't for others ?
Back to top
View user's profile Send private message
PrakashP
Veteran
Veteran


Joined: 27 Oct 2003
Posts: 1249
Location: C.C.A.A., Germania

PostPosted: Fri Oct 08, 2004 10:26 pm    Post subject: Reply with quote

Some use wiser and some use not so wise CFLAGS I would guess.
Back to top
View user's profile Send private message
zeek
Guru
Guru


Joined: 16 Nov 2002
Posts: 480
Location: Bantayan Island

PostPosted: Sat Oct 09, 2004 3:26 am    Post subject: Re: Symlinking libraries for better performance [Sticky requ Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 5818
Location: Removed by Neddy

PostPosted: Sat Oct 09, 2004 10:35 am    Post subject: Reply with quote

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
View user's profile Send private message
PrakashP
Veteran
Veteran


Joined: 27 Oct 2003
Posts: 1249
Location: C.C.A.A., Germania

PostPosted: Sat Oct 09, 2004 10:38 am    Post subject: Reply with quote

BTW, no need to do symlinking in case of doom. Just delete (or rename) the .so files...
Back to top
View user's profile Send private message
Gentii
Guru
Guru


Joined: 01 Feb 2004
Posts: 306

PostPosted: Sat Oct 09, 2004 12:47 pm    Post subject: Reply with quote

PrakashKC wrote:
Some use wiser and some use not so wise CFLAGS I would guess.


And what are wiser CFLAGS ?
Back to top
View user's profile Send private message
PrakashP
Veteran
Veteran


Joined: 27 Oct 2003
Posts: 1249
Location: C.C.A.A., Germania

PostPosted: Sat Oct 09, 2004 1:22 pm    Post subject: Reply with quote

CFLAGS which cause gcc to create fast and stable binaries... :roll: There are plenty of threads about it...
Back to top
View user's profile Send private message
KozmoNaut
Apprentice
Apprentice


Joined: 09 Dec 2002
Posts: 168
Location: Denmark

PostPosted: Sat Oct 09, 2004 1:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
-=GGW=- $ol!d $n4>|e
Veteran
Veteran


Joined: 12 Apr 2004
Posts: 1616
Location: USA

PostPosted: Sun Oct 10, 2004 8:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
hermes_jr
l33t
l33t


Joined: 26 Feb 2004
Posts: 701
Location: Moscow, Russia

PostPosted: Sun Oct 10, 2004 8:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum