home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!sgigate!sgi!quasar.mti.sgi.com!davea
- From: davea@quasar.mti.sgi.com (David B.Anderson)
- Newsgroups: comp.sys.sgi
- Subject: Re: strange compiler behavior
- Message-ID: <v8hosok@sgi.sgi.com>
- Date: 23 Jan 93 22:33:28 GMT
- Sender: davea@quasar.mti.sgi.com
- Organization: Silicon Graphics, Inc. Mountain View, CA
- Lines: 35
-
- In article <1993Jan23.043404.20003@Princeton.EDU> igor@fine.Princeton.EDU (Igor Rivin) writes:
- >
- >Why is it that if you declare an uninitialized global array,
- >three times as much virtual space as necessary gets allocated?
-
- Well it should really be twice as much plus alignment (which can, in unusual
- cases lead to 3X, I admit).
-
- I call this the 'bss bloat' (and it's my fault...). This is ONLY in
- .bss, not in other sections.
-
- The linker is rounding things in bss to page boundaries. It knows that
- at least 2 things there are used as file buffers. By guaranteeing that
- these are on page boundaries the kernel can page-flip the data into
- your running program rather than copying byte-by-byte.
-
- In your release it is rounding everything in bss (individually)
- rather than being selective.
-
- Since it cannot really know all that is in bss, it is forced to
- *duplicate* all the stuff of interest. The extra VM is never
- referenced so is never allocated in swap (depending on
- availsmem_accounting in a file in /usr/sysgen/master.d, of course)
-
- **In the 3.10-IDO linker for 4.0.5 ONLY two things are aligned so
- the bss bloat (all but a little of it) goes away.**
-
- You can turn this off completely with -Xnobsschange (see the ld man page).
-
- In your own programs doing open(2)/read(2)/write(2), do i/o in page
- multiples from page-aligned addresses on disk into page-aligned memory
- and you will, normally, get faster i/o!
-
- Hope this makes some sense.
- [ David B. Anderson (415)390-4263 davea@sgi.com ]
-