2 ms·
> calloc itself calls memset in user space. Have you considered reading my comment past the first phrase? If you don't actually touch the page, the system does
by masklinn 11y ago
> calloc itself calls memset in user space.
Have you considered reading my comment past the first phrase? If you don't actually touch the page, the system doesn't need to allocate it, let alone zero it. If you don't touch the page, assuming you're benching on linux you're measuring the cost of mapping a preexisting zeroed COW page, not the cost of actually allocating that memory.
- heinrich5991 11y agoCalling memset in userspace qualifies as touching the page, no?
- mortehu 11y agocalloc is a library function, as opposed to a system call, so it calling memset is no different from the caller doing so. calloc will do the write in "copy on write". Calling memset on every byte in a buffer should qualify as "touching it". This is why I said "in user space".