Article View: comp.unix.programmer
Article #3548Re: g++: Shared library, mapfiles, execution speed
From: Fred Ma
Date: Fri, 14 Mar 2003 10:08
Date: Fri, 14 Mar 2003 10:08
48 lines
3503 bytes
3503 bytes
Valentin Nechayev wrote:
> `shared' affects execution time in the only way: it requires additional
> time for dynamic linker to load library, parse its export and import
> list, resolve unresolved links in this list. This time is spent once
> on any program startup. It is usually too small, but can be very huge.
> E.g., mozilla-1.0 loads on my at-work Linux box (Intel CC820, Celeron 900)
> for 8 seconds, and 7.5 seconds of them are dedicated to load dynamic
> libraries and resolve cross links. (There are special options in new
> binutils which compresses cross-link lists for faster parsing,
> `-fcombreloc' for ld; this wasn't applied yet to this mozilla package.)
I can live with long startup time. The execution time is much longer,
so that's the important thing.
> FM> I never used the linker explicitly before, relying on gcc to
> FM> pull it all together. Now, I'm looking at "man ld", which
> FM> is the sunOS5.8 man page, and I'm not sure if it is the same
> FM> one that gcc uses. Is there any reason to think otherwise?
>
> It isn't subject to make huge thinking, it is trivially testable.
> Run gcc of any test example (even "Hello world") with -v.
Well, thanks for the advice. It wasn't obvious to me how to
obtain the information, but your suggestion to use -v revealed
that it was the solaris linker.
> FM> In the end, I'm still left with the question of how to
> FM> invoke a shared library function outside of matlab.
> FM> This is for the sake of speed comparison with the
> FM> nonshared version, as the nonshared version is run
> FM> from outside of matlab.
>
> Trivial program will be similar to
> main() {
> int (*func)(int);
> lib = dlopen( "yourlib.so", RTLD_LAZY );
> if( !lib ) { fprintf( stderr, "dlopen(): %s\n", dlerror() ); return 1; }
> func = dlsym( lib, "function" );
> if( !func ) { fprintf( stderr, "dlsym(): %s\n", dlerror() ); return 1; }
> printf( "%d\n", func(1) );
> }
OK, that's quite a bit of new material (can't say I recognize
any of it). I'll have to do some digging and reading before
I make use of it. Thanks.
Fred
Technical Details
Message-ID:
<3E71AA33.F28AB7BE@doe.carleton.ca>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mailReferences:
<3E70F170.B4EE8B07@doe.carleton.ca> <20030314064914.GA355@iv.nn.kiev.ua>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,e2dd6c17ce56ca38 X-Google-Attributes: gid11318c,public X-Google-Thread: 106e3f,e2dd6c17ce56ca38 X-Google-Attributes: gid106e3f,public X-Google-Thread: 11035d,e2dd6c17ce56ca38 X-Google-Attributes: gid11035d,public X-Google-Thread: fc89c,e2dd6c17ce56ca38 X-Google-Attributes: gidfc89c,public X-Google-ArrivalTime: 2003-03-14 02:16:30 PST Message-ID: <3E71AA33.F28AB7BE@doe.carleton.ca> From: Fred Ma <fma@doe.carleton.ca> X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.unix.programmer,gnu.gcc.help,comp.soft-sys.matlab,comp.unix.solaris Subject: Re: g++: Shared library, mapfiles, execution speed References: <3E70F170.B4EE8B07@doe.carleton.ca> <20030314064914.GA355@iv.nn.kiev.ua> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 49 Date: Fri, 14 Mar 2003 05:08:51 -0500 NNTP-Posting-Host: 64.230.75.247 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1047636753 64.230.75.247 (Fri, 14 Mar 2003 05:12:33 EST) NNTP-Posting-Date: Fri, 14 Mar 2003 05:12:33 EST Organization: Bell Sympatico Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail