|
Message-ID: <20170620200445.brsuiy6ssojslmau@voyager> Date: Tue, 20 Jun 2017 22:04:45 +0200 From: Markus Wichmann <nullplan@....net> To: musl@...ts.openwall.com Subject: Re: Query regarding malloc if statement On Tue, Jun 20, 2017 at 04:35:49PM +0200, Szabolcs Nagy wrote: > are you arguing with somebody off-list? > (i only see your replies) > I had a feeling something strange was going on lately. However, Jamie did address his mails to the list. Could someone investigate where they got stuck? Is he in your killfile, perchance? > in any case the calloc code should not be > controversial on linux. > It isn't, but valgrind likes to disagree (that's why I alluded to reclaim() before; valgrind has a habit of playing contrarian to musl). > writing to each allocated page when they are > potentially unused is a huge waste of memory > not just time. (a benchmark that calls calloc/free > in a loop is obviously bogous, try > > calloc(1000*1000*1000,1) > > vs > > memset(malloc(1000*1000*1000),0,1000*1000*1000)) Well, that doesn't test the line in contention as the allocated size is way beyond the mmap threshold; thus __malloc0() won't do anything at all, except call malloc(). The only way that line would make a positive difference is if malloc() were to call expand_heap(), and expand_heap() were to use mmap() to get more memory, and the returned chunk would contain unallocated pages. Since each heap expansion requires the writing of a header and a footer, something between three pages and the mmap threshold would have to be allocated. That's why I suggested using 100 kB. Ciao, Markus
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.