Windows 10: Windows 10 Memory Compression

Page 1 of 2 12 LastLast
  1. Brink's Avatar
    Posts : 33,008
    64-bit Windows 10 Pro build 18252
       20 Aug 2015 #1

    Windows 10 Memory Compression





    With the announcement of the Memory compression feature, we have received a lot of queries from the insiders asking for more information. This post tries to go in-depth into the inner working of the Memory Manager and the memory compression engine built within it.

    One of the primary goals of any operating system is to manage and share resources efficiently. How well an operating system arbitrates competing memory requirements is particularly important, because it impacts the userís perception of system responsiveness.

    In Windows 10, we enabled the Memory Manager (MM) to compress infrequently-accessed memory pages which reduces the amount of reads and writes to the disk (pagefile) and therefore improves responsiveness. By compressing memory we reduce the amount of memory used per process, allowing the operating system to maintain more applications in physical memory at a time before enacting traditional paging.

    When Memory Managerís policy does dictate paging, the data being written to or read from the disk is already compressed to typically around 40 percent of its original size. This compression improves the performance of other unrelated operations on the system by reducing a major source of interfering IO load. The end result is a snappier, more responsive experience with improved app launch performance and consistency.

    Before explaining the Windows 10 changes in detail, Iíll describe some of the fundamental concepts in Windows memory management and give an overview of how it was performed prior to implementing compression.

    Click image for larger version. 

Name:	532af423-004e-4105-8122-4e040dc988ee.png?n=SoftFault%u002520page%u002520still%u002520in%u002520m.png 
Views:	61 
Size:	44.4 KB 
ID:	32873

    The first concept is a working set which is the actively-used physical memory of a process. A private working set represents physical memory that is unique to a process. Processes also touch other pages of physical memory that are ďshared,Ē which several processes can reference. When you look at the Processes view in Task Manager, the memory for a specific process is actually its current private working set. Note that for simplicity when I refer to a ďworking setĒ in this post, I mean a ďprivate working set.Ē

    Some subset of a processís working set pages are likely to be used only infrequently, and since memory is a limited resource that needs to be used efficiently, those pages must be reclaimed and made available for use by other processes. When MM decides a page has been inactive for long enough, it puts it on the modified list. An asynchronous process writes pages in the modified list to the pagefileon disk and then - in memory - moves them from the modified list to the standby list. This write happens so that if the memory is reclaimed from the standby list by another process, but the original process comes looking for its page, the data can be retrieved from the pagefile.

    However, pages on the standby list havenít yet been reclaimed, so they retain their data until MM repurposes them for another processís working set. They can be reused by the app that previously owned them if that app asks for the page before it is reclaimed. This is called a soft fault. But if a page has been repurposed, and the original process asks MM for that page, a hard fault occurs. The original process is now asking for memory that has been taken by another process, and the OS must issue disk read IO to retrieve it.

    As explained earlier, MM, when faced with memory pressure, determines which pages should be moved to the modified list. This is called trimming. But Windows 8 added the ability for Universal Windows Platform (UWP) applications to be swapped out in their entirety - i.e. at app rather than at page granularity. This is done because UWP apps are suspended when not in the foreground meaning they wonít be running until the user switches back them. No page will be touched until the app is brought back in its entirety, so itís safe to swap out the whole application. The disk IO required to swap the application back in is then entirely sequential reads, which are dramatically faster than random reads. For more information about the swapping of UWP apps in Windows 8 MM, see this blog post by Bill Karagounis.

    Windows 10 introduces a layer between the pagefile and normal paging activity which allows for the compression of all pages moved to the modified list. This means that when MM feels memory pressure, it will compress unused pages instead of writing them to disk. MM now only performs disk IO when compression isnít enough to relieve memory pressure. Using this strategy, fewer disk operations are required since - thanks to compression - more data can be stored in memory than before.

    Click image for larger version. 

Name:	3cc98ebf-aeb9-4044-8591-be20da3dd8a0.png?n=InMemoryDecompression.png 
Views:	38 
Size:	58.6 KB 
ID:	32874

    This is achieved by using a concept called a compression store, which is an in-memory collection of compressed pages. Thereís a single system store for legacy Windows desktop apps or any other non-UWP app memory usage, and then one store for each Windows Runtime app (in order to enable trimming and swapping accordingly). Instead of writing pages in the modified list to the pagefile, MM compresses them and places them in the appropriate store.

    The stores live in the system processís working set. Note that in the diagram above weíve displayed the System Working Set separately from the other Working Sets for formatting reasons, but the System Working Set is a working set like any other. Though perhaps counterintuitive at first glance, since the system process holds the stores in memory, its working set grows larger exactly when memory is being made available to other processes. This is visible in the task manager.

    First, observe the amount of memory used by the System process:

    Click image for larger version. 

Name:	bb5152a3-6fd9-40f6-acd7-b82e8779b9ab.png?n=Observe%u002520the%u002520amount%u002520of%u002520mem.png 
Views:	1757 
Size:	106.1 KB 
ID:	32875

    Then, start and suspend some applications:

    Click image for larger version. 

Name:	a731f759-ac2c-471a-b6c4-22e254610df4.png?n=Start%u002520and%u002520suspend%u002520some%u002520ap.png 
Views:	1743 
Size:	60.0 KB 
ID:	32876

    And the System processís working set will grow:

    Click image for larger version. 

Name:	979ea7c0-09b8-45ec-b62f-7ef24a71abdc.png?n=system%u002520process%u002520working%u002520set%u0025.png 
Views:	1740 
Size:	91.1 KB 
ID:	32877

    Each store manages fragmentation by compacting itself when necessary to ensure a good compression ratio. In practice, compressed memory takes up about 40% of the uncompressed size, and as a result on a typical device running a typical workload, Windows 10 writes pages out to disk only 50% as often as previous versions of the OS did. This will reduce the amount of time spent waiting for IO on all devices, but it will also improve the expected lifespan of systems featuring flash-based hard drives.

    Though compression affords the OS more space in memory for a given application load, paging to disk may still be necessary. In Windows 10, this works by moving pages from the stores in the system process to the modified list. If pages come to the modified list from the system process stores, MM knows theyíve already been compressed and are ready to be written to the pagefile. The writes to disk will be smaller since the pages are necessarily compressed, i.e. the only pages MM will write to disk are ones which have been compressed and stashed in a store in the system process.

    So now letís talk about how a process gets its data back either from a compression store or from the pagefile on disk. In the former case where a process faults on a page which is currently in a compressed store, MM simply decompresses the page and puts it back in the requesting processís working set - a soft compression fault. But in the latter case, MM tries the former and finds that the compressed data for the page is not in memory. The system process working set then hard faults on the compressed data for the page and MM reads it back in from disk. Decompression and adding to the faulting processís working set follow.

    Decompression is a highly parallelizable operation, so Windows can be efficient when moving multiple pages at once. Because of that, swapping UWP applications (as opposed to trimming) performs particularly well. But itís not just the decompression: Windows combines that parallelizability with the sequential reads designed into the swapping procedure to read pages into memory extremely quickly; it reads a block at a time, and, while waiting for the next IO operation to complete, itís simultaneously decompressing the data it just read in parallel using multiple CPUs. Where before a platform might have felt sluggish due to the transfer rate of its disk, running Windows 10 the same hardware appears much more responsive.

    In summary, Memory compression allows Windows 10 to make better use of available memory on all systems by reducing physical memory utilization, resulting in fewer pagefile IO operations and a reduced reliance on disk. Furthermore, it improves the speed of writing to and reading from disk when MM determines paging must be enacted. In sum, we expect users to experience improved overall responsiveness and usability on all devices running Windows 10.

    Thanks,
    Ethan Creeger Ė Program Manager in the Base Platform team. I have been in Windows (and Microsoft) for two years work on the hardware aspects of the Kernel such as ACPI and PCIE.
      My ComputersSystem Spec

  2.    20 Aug 2015 #1

    Thanks, that is a good read.
      My ComputerSystem Spec

  3.    20 Aug 2015 #2

    That;s interesting. I have come to love yet hate some of the new hidden items in win10
      My ComputerSystem Spec

  4.    20 Aug 2015 #3

    69matrix69 said: View Post
    That;s interesting. I have come to love yet hate some of the new hidden items in win10

    Welcome to the forum.
      My ComputerSystem Spec


  5. Posts : 91
    64-bit 10240 10 Pro
       20 Aug 2015 #4

    Yes indeed thanks, a very interesting read. I hope it makes it to the RTM soon.
      My ComputerSystem Spec

  6.    21 Aug 2015 #5

    . . .no big deal, along with no problems. . .:)
      My ComputerSystem Spec

  7.    21 Aug 2015 #6

    Will this help Firefox to startup faster and be more performing on the web too?
      My ComputerSystem Spec

  8. Victek's Avatar
    Posts : 232
    Windows 10 x64 v1803 Build 17134.1
       21 Aug 2015 #7

    "In summary, Memory compression allows Windows 10 to make better use of available memory on all systems by reducing physical memory utilization, resulting in fewer pagefile IO operations and a reduced reliance on disk. Furthermore, it improves the speed of writing to and reading from disk when MM determines paging must be enacted. In sum, we expect users to experience improved overall responsiveness and usability on all devices running Windows 10."

    The universal "no free lunch" principal implies that there must be a trade-off here. I'm assuming that memory compression is going to add to CPU load ( ? ) Also I would think that the benefit of memory compression would be seen mostly on systems with less installed ram.

    Now that this feature is available in the latest insider build I'm looking forward to third party reviews.
      My ComputerSystem Spec

  9.    21 Aug 2015 #8

    Each store manages fragmentation by compacting itself when necessary to ensure a good compression ratio. In practice, compressed memory takes up about 40% of the uncompressed size, and as a result on a typical device running a typical workload, Windows 10 writes pages out to disk only 50% as often as previous versions of the OS did. This will reduce the amount of time spent waiting for IO on all devices, but it will also improve the expected lifespan of systems featuring flash-based hard drives.
    Isn't the average lifespan of flash based hard drives already something like 87 years?

    Can we safely assume that if one has a lot of RAM (16GB or more) that this memory compression really isn't going to mean much to them?
      My ComputerSystem Spec

  10.    21 Aug 2015 #9

    I find their statement a bit ambiguous since it doesn't explicitly mention Windows 10 Preview.
    They've introduced it to Windows 10, what else could it be except for Windows 10 or Windows 10 Preview?

    Memory Manager Improvements:


    In Windows 10, we have added a new concept in the Memory Manager called a compression store, which is an in-memory collection of compressed pages...
    Announcing Windows 10 Insider Preview Build 10525 | Blogging Windows
      My ComputerSystem Spec


 
Page 1 of 2 12 LastLast

Related Threads
Has anyone been able to get Infrarecorder to actually work on the screen? It stays in memory, shown in Task Manger, tried both the 32 bit version and 64 bit version, but absolutely will not keep a window open to use the program. Have tried running...
Memory High after Windows 10 update in Performance & Maintenance
I have an HP Omen which I just bought this year and since I upgraded to Windows 10 from 8 it has been soaring in memory usage at certain times and slowing down my computer drastically. It didn't do this before updating the OS. I've tried...
windows memory diagnostic in Performance & Maintenance
howdy, couple days ago ran win 10 built in memory diagnostic tool to find every boot its in taskbar, cant double click/right click on it as nothing happens, have to use task manager to stop it, checked startup/task scheduler but its not set to run...
Yesterday I upgraded my PC from Windows 7 to windows 10, and today I started having problems running games where everything was getting very hitchy. I checked my memory and CPU usage and noticed that my memory is now constantly at 90% or greater....
As soon as I fired up Sony Vegas 13 and started to record (setting up the microphone was a whole other issue), I was presented with a Low Memory Warning (in Sony Vegas). Personally I think I should have adjusted the Virtual Memory ages ago (Win7),...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 14:47.
Find Us