home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / hp / 9733 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  5.6 KB

  1. From: mjs@hpfcso.FC.HP.COM (Marc Sabatella)
  2. Date: Wed, 26 Aug 1992 20:14:28 GMT
  3. Subject: Re: Shared libraries have me very confused!
  4. Message-ID: <7371266@hpfcso.FC.HP.COM>
  5. Organization: Hewlett-Packard, Fort Collins, CO, USA
  6. Path: sparky!uunet!usc!sdd.hp.com!hpscdc!hplextra!hpfcso!mjs
  7. Newsgroups: comp.sys.hp
  8. References: <1992Aug25.053800.24067@news.uiowa.edu>
  9. Lines: 107
  10.  
  11. In comp.sys.hp, dsiebert@icaen.uiowa.edu (Doug Siebert) writes:
  12.  
  13. > No, I meant each runs in a separate process.  They are all run from the same
  14. > i-node
  15.  
  16. OK, then you are getting an awful lot of sharing already.
  17.  
  18. > I used 'monitor' to get this information.  I went by what it told me both by
  19. > analyzing processes individually and giving me their RSS size, and by the
  20. > global statistics giving the overall amount of memory usage.  With 75 users
  21. > I would dig into the first couple megabytes of swap space, though beforehand
  22. > none was used.  I assume this means that at that point physical memory has
  23. > been exhausted and inactive pages are being swapped out.  At some point pages
  24. > that are just *less* active will be swapped out, and then I'll see performance
  25. > decrease, correct?
  26.  
  27. "monitor" probably reports shared library text pages as "belonging" to each
  28. process, so analyzing processes individually won't tell you much.  If the
  29. global RAM usage statistics (which probably can be trusted, but I don't know -
  30. after all, monitor is unsupported) show more total memory being used with
  31. shared libraries, then I guess we can take that at face value.  However, the
  32. increase in swap usage, as I explained earlier, should be expected, and does
  33. *not* mean "physical memory has been exhausted", unless "monitor" really is
  34. showing you the use of swap, and not just the reservation/allocation.  All
  35. swap that a process *might* need to back up its data and bss (and that of its
  36. libraries) is allocated at startup time in HP-UX, as well as SunOS.  AIX, I
  37. believe, does not do this - it allocates swap as pages actually are referenced,
  38. or possibly even only as they need to be swapped out.  The downside of the
  39. Sun/HP was is that per-process swap allocation (albeit not actual usage) goes
  40. up.  The downside of the AIX way is that a process may often find itself in a
  41. position where it doesn't have enough swap to back up its own data, and there
  42. is none available.  At this point, the system would either have to kill off
  43. processes, or make some wait, possibly leading to deadlock and all those nasty
  44. things.  Under the HP/Sun method, either a process has enough swap to start, or
  45. it doesn't.  The only way a process can run out of swap during execution is
  46. through a failed call to malloc(), which well-behaved applications can at
  47. least recover gracefully.  Under the other approach, a process can die, or be
  48. put on hold waiting for swap, possibly indefinitely, at any time.  Actually,
  49. this can happen in HP-UX as well, if you try to grow your stack and there is
  50. not enough swap to back it up, but this is a very rare occurrence.
  51.  
  52. > OK, I think I understand what I was missing about shared libraries.  Since this
  53. > application is the major usage of this machine, and I'm not really concerned if
  54. > it is a couple hundred K larger in size, I should compile with the archive
  55. > libraries instead of the shared libraries, to avoid the overheard of swap, real
  56. > memory, and speed associated with shared libraries, which are intended to save
  57. > disk space over the many applications over the whole system.
  58.  
  59. Good assesment, but:
  60.  
  61. > >    cc -o program.shared $(OBJS) $(LIBS)
  62. > 107889 + 1852 + 18964 = 128705
  63. > >    cc -o program.archive $(OBJS) -Wl,-a,archive $(LIBS)
  64. > 191028 + 12220 + 43712 = 246960
  65. > >    cc -o program.none $(OBJS)
  66. > 105692 + 1524 + 15468 = 122684
  67.  
  68. > I'm guessing you mistyped and meant #1 and #3 should be similar, since #2 has
  69. > the extra overheard of *not* using shared libraries.
  70.  
  71. Correct, sorry about that, but...
  72.  
  73. > But #2 does take up less
  74. > memory, according to monitor (though you say that may be flawed)
  75.  
  76. Right.  Running "monitor" on #2 presumably shows 190K of memory used for text
  77. by the process - 100K belongs to the application, 90K to the library code.
  78. However, there was originally probably more like 200K of code in those
  79. libraries, and when you use the shared versions, "monitor" probably reports
  80. that 200K as belonging to each process, even though it is really shared.  So
  81. "monitor" probably reports around 300K of memory used for text per process.
  82. Since this is all text, and shareable, it does't matter how many invocations
  83. of the program are present; that's all the memory that will be needed for
  84. text.  So it looks like the shared version needs 110K more.  However, if you
  85. have only 2 other applications that use 90K of library text, then shared
  86. libraries will be a win - the two other applications will need
  87.  
  88.     App1-text + 90K + App2-text + 90K
  89.  
  90. memory for text with archive libraries, whereas with shared libraries, only
  91.  
  92.     App1-text + App2-text
  93.  
  94. memory for text.  The 180K savings just wiped out the 110K cost you saw without
  95. those 2 other applications.
  96.  
  97. > The only
  98. > library other than libc I am using is the curses/termcap library, so there is
  99. > not much tuning I can do in that respect.
  100.  
  101. The curses library is pretty small, and can probably be discounted.  In fact,
  102. I don't think it is even available in shared form.  So it is really only libc
  103. we are talking about here.  libc actually contained >600K of text, so monitor
  104. will probably show any given process as requiring 510K more memory with shared
  105. libc than with archive libc.  But you aren't *really* using that much memory.
  106.  
  107. --------------
  108. Marc Sabatella (marc@hpmonk.fc.hp.com)
  109. Disclaimers:
  110.     2 + 2 = 3, for suitably small values of 2
  111.     Bill (H.) and Dave (P.) may not always agree with me
  112.