现在的位置: 首页 > 综合 > 正文

Why Windows Cache Can Exceed Its Virtual Size

2013年01月06日 ⁄ 综合 ⁄ 共 1896字 ⁄ 字号 评论关闭
Why Windows Cache Can Exceed Virtual

Fan Decheng
2007-06-26

These days I have been not understanding why Windows cache is not limited to the maximum cache virtual size 960MB. This is said in the "Cache Physical Size" section in the Windows Internals, 4th Edition book.

The reason is, Cache Manager uses sections objects (or called memory mapped files) to do caching. A section object maps a view of a file or a view of a certain amount of memory (RAM plus the paging file) into a virtual address range. Thus, the section object can be shared among applications.

There are two stages of a section object view access. The first stage is to map the view. After mapping the view, the virtual address space corresponds to the view of the file or amount of memory. The second stage is to access the pages. When a page is accessed, it is read into the RAM by the memory manager (by calling the file system driver).

In the case of the Cache Manager, only views of files are related. As we know, there are VACB arrays. Each one of them correspond to a section object mapping a view of a 256KB block of a file. Now, it is said that the virtual size of the cache is 960MB. This means that the virtual address space occupied by the section objects add up to no more than 960MB.

For example, when a part of a file is being accessed, the file system driver asks the Cache Manager to get the part. The Cache Manager checks to see if the part of the file is mapped in one of the section objects. If it is, then the Cache Manager accesses the virtual memory pages to retrieve it. If it is not mapped, then the Cache Manager maps a view of it through Memory Manager. But at that time, it is still not read from the disk. However, immediately the Cache Manager accesses the pages. Then the Memory Manager reads the file from the disk by calling the file system driver.

Sometimes the pages are already in RAM. It may be in the cache working set or in the standby list. Even unmapped views of files may still stay in the standby list. The cache working set means pages that are accessed by the Cache Manager so that they are referenced by page tables for the system cache.

The reason why the Cache Manager has a virtual size possibly larger than the RAM is for efficiency. Mapping and unmapping views is slow, so it is best avoided when not necessary.

抱歉!评论已关闭.