3 ms·
This may be over-optimization. Allocating all-zero pages as copy-on-write doesn't reduce zeroing overhead. It just postpones it until the page is used, at which
by Animats 10y ago
This may be over-optimization. Allocating all-zero pages as copy-on-write doesn't reduce zeroing overhead. It just postpones it until the page is used, at which time zeroing takes place. Possibly at a higher cost, because you now have to take a page fault, allocate a page, mess with the MMU, and only then zero the page. Only for programs which allocate vast amounts of memory which they then never write is this a win.
Is that common?
- brigade 10y agoIf you zero upfront, you have to do all of that save the page fault anyway, but for large allocations you also thrash the cache zeroing stuff that's immediately evicted to memory. It really is faster in general to zero a page when the program actually touches it, since that's when the program wants it in cache (for certain thresholds of "large allocation")
- haimez 10y ago"Thrashing to memory". Man, we must have different SLOs.
- loeg 10y agoThe operating system can perform page zeroing during low load times and give out zero pages "for free" during higher load times. (So this can serve to smooth out CPU usage in spiky loads.) Or the OS may use special hardware that is inaccessible to userspace (e.g., Intel I/OAT) to zero pages in a way that doesn't consume CPU cycles.
- Achshar 10y agoWouldn't it also help that the program would most certainly not write the entire large chunk of memory all at once. So the cost of copy-on-write zeroing is postponed and divided to individual write operations performed by the program instead of all of it happening up front at once.