Date: Sat, 14 Sep 1996 10:31:44 +0200 (MET DST) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: bde@zeta.org.au (Bruce Evans) Cc: current@freebsd.org Subject: Re: pentium-optimized bzero and bcopy Message-ID: <199609140831.KAA13017@labinfo.iet.unipi.it> In-Reply-To: <199609140649.QAA06910@godzilla.zeta.org.au> from "Bruce Evans" at Sep 14, 96 04:49:02 pm
next in thread | previous in thread | raw e-mail | index | archive | help
On the bzero subject, does someone have statistics on the usage of bzero on large (>2pages) chunks of memory ? Here is why I am asking. If you declare char foo[A_LARGE_CONSTANT]; this goes into BSS, which is zero filled on demand. Hence, if you only use a part of this large buffer, you do not consume physical memory or swap space. (I have tried to force a core dump on many programs, and I noticed that no single program "uses" less than 20 fully-zeroed pages. I guess this is something which comes with libc, probably because of some memory overallocation.) On the other hand, you might think that it is cleaner to initialize foo[], and call bzero(foo, sizeof(foo)); in your program. At this point, I think these pages become mapped and zeroed, thus consuming memory, unless bzero() can intercept such an occurrence and invoke a system call to unmap the required pages. This is not much of a problem for ordinary programs, or for library code, as the system's architect might be aware of the difference and allocate memory in the most efficient way. But how about user programs ? As an example, I often run simulations using large hash tables, and I think I could gain some performance from a modified bzero(). However, I agree that if this is going to be a very rare occurrence, then it is not worth changing things and (probably) add another system call. Any comments ? Luigi ==================================================================== Luigi Rizzo Dip. di Ingegneria dell'Informazione email: luigi@iet.unipi.it Universita' di Pisa tel: +39-50-568533 via Diotisalvi 2, 56126 PISA (Italy) fax: +39-50-568522 http://www.iet.unipi.it/~luigi/ ====================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609140831.KAA13017>