[MPlayer-dev-eng] [RFD] Something...
Gábor Lénárt
lgb at lgb.hu
Sun Apr 13 09:04:08 CEST 2003
On Sat, Apr 12, 2003 at 04:37:58PM -0400, D Richard Felker III wrote:
> On Sat, Apr 12, 2003 at 09:30:45PM +0200, Gábor Lénárt wrote:
> > On Fri, Apr 11, 2003 at 09:17:19PM -0400, D Richard Felker III wrote:
> > > > uses glib2, but probably doesn't depend on gtk. Using something like
> > > > glib2 is probably better than hacking up your own method.
> > >
> > > glib is disgusting too, and glib2 even moreso. In helping with irssi
> > > support on irc over the past year or so, one of the top things users
> > > have been annoyed about is the glib dependence.
> >
> > But this is exactly the key problem of today's Linux system. Almost EVERYONE
> > writes own code for the SAME thing which should be in shared libraries only
> > once. OK, case of windows is even worse (there is no choice in many cases),
> > but the redundant code in each softwares means slower startup (just see
> > complex programs like openoffice of mozilla) and memory wasting ...
>
> This is total nonsense. Bloated shared libs make for MUCH slower
> startup than writing simple minimal implementations of this stuff as
Hmm, I didn't write about situations where a huge lib is used just for
one or two functions which can be implemented in few dozens of byte of
code in your program :) But about a year ago I finished a little project
where I calculated memory usage by a tipical GUI ;) Linux user. So eg if he
use gnome, glib is used by several running processes it's much cheaper to
use glib for a newly launched process. Of course not if you're using KDE
instead. And so on. OK, it's hard to messure these facts in GENERAL but only
for a well defined situation.
> it's needed. The problem is brain damaged "object oriented"
> programming. Yes it will be slow if you make a generic full-featured
OO is really brain damaged I also think that :)
> linked list 'object' in your program, and do the same for string,
> resizable array, hash table, etc. etc. etc. -- BUT it will also be
> slow if you use glib[2] to do the same thing!! Instead you should
> write just what you need. In most cases, you only need a pointer
> (struct whatever *next) and a few lines of code to manage a linked
> list, not a few megs of glib crap!
It's NOT that simple. For most cases maybe you're right. But not always.
First of all, optimizing for memory usage and optimizing for speed are somewhat
different things and cannot be done easily for these two goals at the same
time!
And you should take care about analizing the actual situation to discover
the best solution. Also, the best it to linking against a home made libc
statically ;-) But this will end in memory wasting. I only wanted to say that
you should find the optimal midway.
I'm not talking about a certain situation but only in general that you shouldn't
refer al libraries as unusable ones. If you do, implement libc as well in
your program. Sure, it will be somehat faster :)
> > So probably using glib or glib2 is a GOOD idea because if multiple programs
> > using them, they will have shared library memory usage (at least at the side of
> > code size in memory, because code segment is shared).
>
> >From what I understand, this also makes code slower because it has to
> use PIC! If you want performance, your shared libraries will be built
> without PIC, and then they use additional memory for each different
> binary running that's linked to them.
Yes, on x86 architecture this can take even 10% of performance, because x86
platform has too few regiters and we must use one for storing GOT to
calculate from global offset table. But it also true that it depends on
the usage! So if the example situation code is NOT time ctritical it could be
nice. HOWEVER, eg in case of mplayer core, implementing a codec in shared
object may result in heavy performance loss ... Or just read documentation
of mysql, it says thet performance can be tuned up by static linking about
libraries.
So in a nutshell, I didn't want to write that you should use should use glib
just for using a few functions within a time critical loop, I only wanted to
write that you should be carefull to analyze the situation for a given
example.
- Gábor (larta'H)
More information about the MPlayer-dev-eng
mailing list