November 9th, 2016

Zeroing out my memory does cause them to page in faster after all

Not too long ago, I answered the question “If I zero out my memory pages, does that make them page in faster?” with “No.”

Turns out that I was working from outdated information.

My former colleague Adrian Oney (who, among other things, has shared with us the story of the USB Cart of Death) confirms the information in the white paper shared by commenter John Doe, namely that starting in Windows Vista, the memory manager does check whether a page that is about to paged out consists entirely of zeroes. If so, then the memory manager turns the page into a demand-zero page rather than a page stored in the pagefile (that happens to contain nothing but zeroes).

Adrian said that he wrote the original prototype which confirmed that the extra check was worth it. “Some of this was due to apps dirtying their zero-init pages with inits to zero. Some of it was due to user mode zeroing pages for security reasons. But it was common enough to make it worthwhile.”

I suspect that the increasing use of virtualization may contribute to this virtuous cycle as well. If the app is running in a virtual machine, then it’s a big win to avoid having to perform virtualized I/O.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.