On Tue, May 18, 2010 at 8:55 PM, Corentin Chary <corentin.ch...@gmail.com> wrote: > I believe that if the allocation size is large enougth, getting a > zeroed page can be almost free with clever memory management. > Could you try to re-run your test with calloc and see what it does ? > Speeding up all mallocz calls is probably a good idea :)
I think that scenario is libc using mmap to grab zeroed pages from the kernel. If the kernel manages zeroed pages so that zeroing is performed out-of-line (e.g. there is a pool of zeroed pages waiting), then it appears that calloc() is getting zeroed memory cheaply. I'll rerun with profiling tomorrow to see if calloc() makes a difference for general qemu_mallocz() usage. In the case of virtio-blk requests, we definitely shouldn't be clearing that memory even if calloc() were cheaper. Much of the request structure will not be touched in an average I/O request. Using zeroed pages is wasteful because they aren't needed here. Stefan