[NTExport logo] Copyright © 1997 Bryce Cogswell and Mark Russinovich last updated April 13, 1997 Controlling the NT system cache Introduction Windows NT provides system administrators with virtually no control over the system cache's sizing and write-back behaviors. Other than specifying that it should be Large or Small (the definitions of which are not documented by Microsoft), none of the cache's parameters can be altered. The Cache Manager uses a variety of complex equations to determine when it should grow and shrink, and when it should write dirty data back to disk. By using unexported global variables, as well as unexported functions, Cacheman is able to provide caching control to a degree never before possible. Cacheman obtains addressed of these variables by using our NTExport utility, which creates function and variable libraries that enable access to every function and global variable in NT. Cacheman's primary purpose is to serve as an example of an application that demonstrates NTExport's utility, but as a by-product it is the most advanced NT cache management tool in existence. Use Cacheman to explore alternate NT system caching parameters to see if performance can be increased for particular applications (or in general!). Using Cacheman To run Cacheman, simply copy the executable and driver to a local hard drive and type "cacheman". The Cacheman dialog dynamically loads the Cacheman driver. Cacheman presents Cache Manager tuning parameters as groups of related settings. Alter the settings you desire and then direct Cacheman to enforce your choices. Here is a brief description of each of the variables that Cacheman lets you change. While running Cacheman you can use the dialog help pointer to obtain these descriptions in a help balloon. Note that these are our best guesses as to what these variables represent and may not be totally accurate. * CcFirstDelay Delay before writing back a page after first access * CcIdleDelay Idle period to wait before writing back dirty pages * CcCollisionDelay Delay by this amount if writeback not possible * CcTargetCleanDelay Standard delay before writing back dirty data * CcDirtyPageThreshold Maximum number of dirty pages to allow in cache * CcDirtyPageTarget Desired number of dirty pages in cache * CcAvailableMaxDirtyWrite Maximum number of dirty pages to write back at a time * CcAvailablePagesThreshold Require at least this many pages available * MmSystemCacheWsMinimum Minimum size of the working set of the cache * MmSystemCacheWsMaximum Maximum size of the working set of the cache * MmDoPeriodicAgressiveTrimming Agressively reduce working sets of all tasks * MmPeriodicAgressiveTrimMinFree Trim working set of cache if available pages greater than this amount * MmPeriodicAgressiveTrimMaxFree Trim working set of cache if available pages less than this amount * MmPeriodicAgressiveCacheWsMin Trim cache to this amount periodically * MmWorkingSetReductionMaxCacheWs Trim cache by this amount if larger than max size * MmWorkingSetVolReductionMaxCacheWs Trim cache by this amount if larger than max size during volume reduction Cacheman does not perform validity checking on input values so it is possible that entering inappropriate settings will result in the system becoming unstable or crashing. Changes to most of these variables will not immediately have a noticeable affect on the Cache's behavior or size unless the system is under heavy memory load. We have not spent much time experimenting with different values, so if you obtain benchmark performance results of the standard caching policy compared to one you have enabled, we would be interested in posting them. Cacheman runs on NT 4.0 Final Release, SP1 and SP2. Cacheman Screenshot Here is a screenshot of Cacheman. Building The Cacheman dialog box was built with Visual C++ 4.2 and Cacheman its source is under gui\. The driver was built on NT 4.0. To build the driver you must first build an unexported function library with NTExport (see NTExport documentation for how to do this). The source for the library code is under dd\lib in the source tree. Once the library is built the driver (under \dd) can be compiled with the NT Build tool. Warning Cacheman uses an unorthodox method to obtain pointers to internal NT variables. Microsoft neither condones nor supports this method. While advanced functionality can be obtained using the techniques presented in this example, you should not use NTExport libraries in your code unless there is no other way to accomplish what you desire. Your driver will be NT-version dependent if it does. Microsoft has the right to change any undocumented and unexported variables and functions. For more information see NTExport. ---------------------------------------------------------------------------- Download Cacheman (46KB) Download Cacheman Source Code (96KB) [Image]