I found this online: http://unixhelp.ed.ac.uk/CGI/man-cgi?posix_memalign. Note in particular, "For all three routines, the memory is not zeroed." Regarding the lack of "man memalign," have you tried texinfo instead? (There isn't a linux machine handy right now so I can't check myself.) --Andy
-----Original Message----- From: Dan Sugalski [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 08:16 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Add #22337 At 11:00 PM +0200 5/27/03, Leopold Toetsch wrote: >Dan Sugalski <[EMAIL PROTECTED]> wrote: >> At 8:03 PM +0200 5/27/03, Leopold Toetsch wrote: >>>... . We need some tests, from which size memory is >>>cleard for malloc and memalign. > >>>I tossed the memset for now and saved ~450.000 L2-misses or ~0.2 s. > >> While I didn't see any memsets in smallobject.c, I'm really, >> *really* uncomfortable counting on implied behavior. > >First, I did write above sentence - "We need some tests...". Second, in >malloc.c (UTSL) its clearly stated that mmap() does yield zeroed >memory. So, for linux and this size of allocation its save to assume >that the memset is not necessary. That's it. LEA (and glibc) malloc >have the same assumptions. I generally wouldn't trust comments in the source for standard libraries if they're not backed up by actual documentation. Internals change, and I'd *really* hate to find ourselves in a position where someone upgrades a system libc, or does an OS point release upgrade, and all of a sudden parrot starts breaking. That wouldn't be at all good. If we can find documentation (not comments in source) that guarantees that we can get zero-filled memory, that's fine and we should. If not, we can't count on it. >The problem is not, "counting on implied behaviour", the problem, is >can we have a memalign() for a specific size, that yields zeroed >memory, where size is rather big - in regions where calloc() AFAIK all >return zeroed memory. > >If calloc() would use memset() to clear the memory you could forget all >performance. I think you'll find that calloc does use memset, or something like it, in some cases. When it hands back memory that was on the freelist it undoubtedly does. When it allocates new memory to satisfy the request it probably doesn't, just asking for zero-fill newly faulted memory from the system. The problem we're going to run into is that this is all terribly system-dependent. Our requests are large enough to reasonably grab (and later release) new memory from the OS, rather than relying on any sort of memory allocation free list, but every system does it differently. That, as much as anything, argues for an entry in platform.c to get and return large sections of memory. I know it's reasonably doable on a lot of platforms, just potentially differently everywhere. >$ man memalign >No manual entry for memalign Yeah, it seems depressingly rare. -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk