< Day Day Up > |
In the following sections, we'll explain how Windows computes the size of the system cache, both virtually and physically. As with most calculations related to memory management, the size of the system cache depends on a number of factors, including memory size and which version of Windows is running. LargeSystemCacheAs you'll see, the registry value HKLM\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\LargeSystemCache influences both the virtual and physical sizes of the cache. The value is 0 by default on Windows 2000 Professional and Windows XP and 1 on Windows Server systems. You can adjust this value through the GUI on Windows 2000 Server systems by modifying the properties of the file server service. (Bring up the properties for a network connection, and double-click File And Printer Sharing For Microsoft Networks.) Even though this service exists on Windows 2000 Professional, its parameters can't be adjusted. Figure 11-4 shows the dialog box you use on Windows 2000 Server systems when modifying the amount of memory allocated for local and network applications in the Server network service. Figure 11-4. File And Printer Sharing For Microsoft Networks Properties dialog box, which is used to modify the properties of the Windows 2000 Server network serviceThe setting shown in Figure 11-4, Maximize Data Throughput For File Sharing, is the default for Server systems running with Terminal Services installed the LargeSystemCache value is 1. Choosing any of the other settings will set the LargeSystemCache value to 0. Although each of the four settings in the Optimization section of the File And Printer Sharing For Microsoft Networks Properties dialog box affect the behavior of the system cache, they also modify the behavior of the file server service. On Windows XP and Windows Server 2003, you can modify LargeSystemCache in the Performance Options dialog box that you access by clicking the Settings button on the Advanced page of the System control panel applet, as shown in Figure 11-5. Selecting System Cache in the Memory Usage area of the Advanced tab sets the LargeSystemCache value to 1, while choosing Programs sets it to 0. Figure 11-5. LargeSystemCache setting on Windows XP and Windows Server 2003Cache Virtual SizeThe virtual size of the system cache is a function of the amount of physical memory installed. The default size is 64 MB. If the system has more than 4032 pages (16 MB) of physical memory, the cache size is set to 128 MB plus 64 MB for each additional 4 MB of physical memory. Using this algorithm, the virtual size of the system cache for a computer with 64 MB of physical memory will be: 128 MB + (64 MB - 16 MB) / 4 MB * 64 MB = 896 MB Table 11-1 shows the minimum and maximum virtual size of the system cache on different systems, along with the start and end addresses. If it's running on an x86 system and the system calculates a cache virtual size that is greater than 512 MB, the virtual size is limited to 512 MB unless the LargeSystemCache registry value is 1, in which case the cache is assigned up to 960 MB of virtual memory that includes an additional address range known as cache extra memory. The benefit of assigning more virtual memory to the cache is that, in general, it results in fewer view unmaps and remap operations as different files and different views of files are accessed.
Table 11-2. lists the system variables that contain the virtual size and address of the system cache.
Cache Working Set SizeAs mentioned earlier, one of the key differences in the design of the cache manager from that of other operating systems is the delegation of physical memory management to the global memory manager. Because of this, the existing code that handles working set expansion and trimming as well as managing the modified and standby list is also used to control the size of the system cache, dynamically balancing demands for physical memory between processes and the operating system. The system cache doesn't have its own working set but rather shares a single system set that includes cache data, paged pool, pageable Ntoskrnl code, and pageable driver code. As explained in the section "System Working Set" in Chapter 7, this single working set is called internally the system cache working set even though the system cache is just one of the components that contribute to it. For the purposes of this book, we'll refer to this working set simply as the system working set. Also explained in Chapter 7 is the fact that if the LargeSystemCache registry value is 1, the memory manager favors the system working set over that of processes running on the system. You can examine the physical size of the system cache compared to that of the total system working set as well as page fault information on the system working set by examining the performance counters or system variables listed in Table 11-3.
Cache Physical SizeWhile the system working set includes the amount of physical memory that is mapped into views in the cache's virtual address space, it does not necessarily reflect the total amount of file data that is cached in physical memory. There can be a discrepancy between the two values because additional file data might be in the memory manager's standby or modified page lists. Recall from Chapter 7 that during the course of working set trimming or page replacement the memory manager can move dirty pages from a working set to either the standby list or modified page list, depending on whether the page contains data that needs to be written to the paging file or other file before the page can be reused. If the memory manager didn't implement these lists, any time a process accessed data previously removed from its working set the memory manager would have to hard-fault it in from disk. Instead, if the accessed data is present on either of these lists, the memory manager simply soft-faults the page back into the process's working set. Thus, the lists serve as in-memory caches of data that's stored in the paging file, executable images, or data files. Thus, the total amount of file data cached on a system includes not only the system working set, but the combined sizes of the standby and modified page lists as well. An example illustrates how the cache manager can cause much more file data than that containable in the system working set to be cached in physical memory. Consider a system that acts as a dedicated file server. The system has 8 GB of physical memory and the cache virtual size is 960 MB (the maximum on x86 systems). The maximum amount of file data that can be directly mapped in the cache's virtual memory is therefore 960 MB. A client application accesses file data from across the network and server, the file server driver (\Windows\ System32\Drivers\Srv.sys, described in Chapter 12), uses cache manager interfaces to read and write file data on behalf of the client. If the client reads through several thousand files of 1 MB each, the cache manager will have to start reusing views when mapping the 961st file. For each file read thereafter, the cache manager unmaps views and remaps them for new files. When the cache manager unmaps a view, the memory manager doesn't discard the file data in the cache's working set that correspond to the view, it moves the data to the standby list. In the absence of any other demand for physical memory, the standby list can consume almost all the physical memory that remains outside the system working set. In other words, virtually the entire 8 GB of the server's physical memory will be used to cache file data, as shown in Figure 11-6. Figure 11-6. Example of where most of physical memory is file cacheBecause the total amount of file data cached includes the system working set, modified page list, and standby list the sizes of which are all controlled by the memory manager it is in a sense the real cache manager. The cache manager subsystem simply provides convenient interfaces for accessing file data through the memory manager, and it plays an important role with its read-ahead and write-behind policies in influencing what data the memory manager keeps present in physical memory. To try and accurately reflect the total amount of file data that's cache on a system, both Task Manager and Process Explorer show a value named System Cache in their performance view that reflects the combined sizes of the system working set, standby list, and modified page list. Figure 11-7 shows the system information view in Process Explorer and the System Cache value in the Physical Memory area in the middle of the figure. Figure 11-7. Process Explorer's System Information dialog box |
< Day Day Up > |