home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / bsd / 10292 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  3.6 KB

  1. Xref: sparky comp.unix.bsd:10292 comp.unix.wizards:5255
  2. Path: sparky!uunet!mcsun!uknet!gdt!aber!aberfa!pcg
  3. From: pcg@aber.ac.uk (Piercarlo Grandi)
  4. Newsgroups: comp.unix.bsd,comp.unix.wizards
  5. Subject: Re: Shared lib benchmarks, and experiences
  6. Message-ID: <PCG.92Dec11191433@aberdb.aber.ac.uk>
  7. Date: 11 Dec 92 19:14:32 GMT
  8. References: <1992Dec3.071056.27426@ntuix.ntu.ac.sg>
  9.     <1992Dec9.213442.18980@serval.net.wsu.edu>
  10. Sender: news@aber.ac.uk (USENET news service)
  11. Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
  12. Organization: Prifysgol Cymru, Aberystwyth
  13. Lines: 58
  14. In-Reply-To: hlu@eecs.wsu.edu's message of 9 Dec 92 21: 34:42 GMT
  15. Nntp-Posting-Host: aberdb
  16.  
  17. On 9 Dec 92 21:34:42 GMT, hlu@eecs.wsu.edu (H.J. Lu) said:
  18.  
  19. hlu> (othman (EEE/Div 4)) writes:
  20.  
  21. othman> I've installed Joerg's shared lib with little problem.
  22. othman> The improvement in code size is significant for small programs
  23. othman> but can be worse for larger programs such as cc1. cc1 using
  24. othman> shared lib is actually larger than static lib, but SysV manual
  25. othman> warns of this problem.
  26.  
  27. hlu> Very strange. I though shared libs always won. At least it is true
  28. hlu> under Linux. No matter how large/small the program is, the code
  29. hlu> size is always smaller if the program is linked with shared lib.
  30.  
  31. I think 'othman' was referring to the (dynamic) working set size, not
  32. the (static) code size, as this was what the SysV manuals were referring
  33. to.
  34.  
  35. Shared libraries often make an executing process' working set larger, if
  36. they are not built such that procedures are likely to be invoked next to
  37. each other in time are next to each other physically. With nonshared
  38. libraries only the .o files actually required by the program get linked
  39. with it, and usually each .o gets linked in immediately after the first
  40. reference to a procedure in it, which also helps ensure that there is
  41. some better clustering.
  42.  
  43. It would be nice to have a tool that does a clustering of procedures
  44. based on their *dynamic* reference patterns, so as to minimize the
  45. working set of a shared library; lacking this I always build a shared
  46. library using "`lorder *.o | tsort`" rather than "*.o"; putting the
  47. object files in linearized call order should _help_ ensure that
  48. procedures that call each other statically are next to each other.
  49.  
  50.   Note that this only only clusters together .o files that refer *to
  51.   each other* and *statically*. It would be best to cluster together .o
  52.   files whose procedures are called next to each other by the average
  53.   client of the library, but without profiling, we cannot know.
  54.  
  55. A reason for hope is that on unloaded machines there is plenty of free
  56. memory and so working set size matters less; on loaded machines several
  57. processes are going to share a given library (hopefully), exercising
  58. different parts of it, so (hopefully) the working sets will overlap and
  59. cover most of it, minimizing the problerm of reducing each. Also, if
  60. several processes are sharing a library, the savings because of the
  61. sharing will likely overwhelm the rise in working set for each process.
  62.  
  63. This means that the likes of libc, libXt and libX11 should be shared;
  64. odds are that lots of *different* executable images will refer to them.
  65.  
  66.   The benefits for a shared library accrue if there are many different
  67.   executable *images* using it, not *processes*; if there are many
  68.   processes, but all arise from the same executable image, then whatever
  69.   library is linked in that image is already shared with that image's
  70.   text section.
  71. --
  72. Piercarlo Grandi, Dept of CS, PC/UW@Aberystwyth <pcg@aber.ac.uk>
  73.   E l'italiano cantava, cantava. E le sue disperate invocazioni giunsero
  74.   alle orecchie del suo divino protettore, il dio della barzelletta
  75.