Understand Windows 10 memory compression

Q. What is the memory compression feature in Windows 10?

A. Windows 10 introduces a new memory compression feature which is designed to reduce the number of hard page faults which impact performance as physical disks are used to store the pagefile which is where memory that is paged out is store. A hard page fault is where pages (4 KB blocks of memory) have to be fetched from the pagefile back into memory which is magnitudes times slower then pages in memory. Typically the more RAM in a machine, the less paging is required since more data can be stored in RAM but when the memory requirements  of the OS and applications exceed RAM then data has to be paged. Most machines today typically have very powerful processors with multiple cores so leveraging CPU to compress and decompress memory makes sense to not only make better use of the RAM in your machine to improve performance and by reducing paging to disk you will actually increase the lifetime of your disk as frequent writes eventually degrade disks, especially SSDs. The CPU cycles for compression run at a low priority to not interfere with other processes running on the machine and the decompression is very fast (around 1 GB per second per core) when pages are needed by an application again. Note that while extra CPU is used it saves disk IO which would typically use CPU anyway.

This technology has evolved from the Readyboost technology originally seen in Windows 7 that used a compressed cache on a USB stick to improve performance to store data also written to the pagefile making it faster to access (compared to a regular spinning disk). Windows 8 evolved this by moving the cache into regular memory but data was also still written out to the pagefile but once again made page faults faster since they could be served from the RAM based cache. The Windows 8.1 Spring update changed this by the cache switching to now being its own compressed pagefile in RAM that could be paged out to disk if required but this only was used with low memory machines for modern applications. Windows 10 changes this to now apply to all systems and all types of applications, Any data you now find in your disk-based pagefile is compressed now after initially being compressed in the RAM based pagefile first and only written to disk as a lack of resources required.

Normally pages that are not used from an applications working set are trimmed out to the modified list and then as required are written to the pagefile based on system resources. If the pages are subsequently needed they are read back from the pagefile (a hard page fault) and put back in the applications working set. In addition Windows has a standby list (think memory cache) where pages written to the pagefile are stored as resources allow to enable a much faster soft page fault if the page is subsequently required by the application. What the big Windows 10 change impacts is the write from the modified list to the pagefile. Instead of pages written directly to the pagefile they now get written to "the compression store" which is user mode memory owned by the System process which historically has been empty since most of its memory was kernel mode. This content is compressed to around 30% of their original size therefore allowing more content to be kept in memory since the remaining 70% of space can now be given to the free page list ready to be used by applications as needed. Note that if the memory still has pressure then pages from the compression store (user mode System process space) can be placed on the modified list (they are now compressed) which can then be written to the physical pagefile (the system will see they are from the system user mode space and compressed and therefore won't try to put them back in the store). Note this is very rare on all but the most memory constrained systems. Within the System memory, modern applications get their own individual stores where as other processes will use a generic system store. Below shows this in picture form.

The upshot of this is that most data will be kept in memory reducing pagefile use but you will see System using lots more memory since this is essentially the in-memory, compressed pagefile content.

This runs across Windows 10 on any device including mobile devices.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish