From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] Virtual memory & paging From: geoff@collyer.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20020204103944.36F5419A27@mail.cse.psu.edu> Date: Mon, 4 Feb 2002 02:38:16 -0800 Topicbox-Message-UUID: 4b24b120-eaca-11e9-9e20-41e7f4b1d025 There isn't a copy of the entire C library in every binary. There is a copy of each library routine called, directly or indirectly, by the program in question. Sharing of instructions is done at the granularity of process text segments, as in V6 or V7 Unix. The text segment of a process that forks is shared between parent and child by page mapping. Also, running (via exec) a program multiple times concurrently causes the (pure) text segment to be shared by page mapping across those processes. So all copies of rc and on a machine should share a text segment. Given that degree of sharing, the low cost of RAM, and the increase in OS complexity, slowness and insecurity in the implementations of dynamic libraries that I've seen, I don't see a need for dynamic libraries. (Remember that the real impetus for adding them to Unix was X11 and its big and badly-factored libraries, which most of us aren't blessed with.) My terminal has 115 processes; all but 4 of them share their text segment with at least one other process, usually more. 74 of them are instances of rio, Mail, rc, acme, listen, plumber and samterm. A CPU server has 141 processes; all but 2 share text. 80 of them are listen, another 21 are rc, exportfs, kfs, dns and consolefs. A quick sampling suggests that Plan 9 programs are typically smaller than FreeBSD/386 programs even with shared libraries. Here are some FreeBSD sizes: : unix; size /bin/cat /bin/ed /usr/bin/awk /usr/X11/bin/sam text data bss dec hex filename 54188 4324 9760 68272 10ab0 /bin/cat 122835 8772 81920 213527 34217 /bin/ed 135761 4772 15756 156289 26281 /usr/bin/awk 52525 1412 53448 107385 1a379 /usr/X11/bin/sam Of those, awk and sam use shared libraries. The corresponding Plan 9 sizes are: ; cd /bin; size cat ed awk sam 15996t + 2208d + 944b = 19148 cat 45964t + 4212d + 41232b = 91408 ed 114731t + 35660d + 12040b = 162431 awk 86574t + 7800d + 66240b = 160614 sam and the Plan 9 programs cope with Unicode and UTF.