3 ms·
>"Unless you are memsetting hundreds of MBs of memory" Not hundreds but in one of my apps I do have 10th MB of continuous cache that has to be zeroed before us
by FpUser 5y ago
>"Unless you are memsetting hundreds of MBs of memory"
Not hundreds but in one of my apps I do have 10th MB of continuous cache that has to be zeroed before use / reuse.
- knome 5y agoI wonder if someone was zeroing enough memory, where the memory is a private anonymous mapping, they might use madvise() with MADV_DONTNEED, which in linux will effectively zero the pages. It returns the memory to the OS, and will pagefault on later accesses remapping them as zero-filled. It works in pages. Sizes smaller than a page result in whatever else is in the same page getting nuked. If you don't immediately reuse the whole cache, it might spread out the zeroing/remapping over time, rather than in a single large go. Imagine some testing would be in order to see if a syscall + mapping changes ( require reloading with TLB for the process ? ) would be smaller than a straight run of writing zeros at some point. IIRC, the zeroing is not something you can expect from non-linux madvise implementations.